np在這種情況下是numpy。python列表操作修改列表形狀
z_mesh是形狀爲41 * 401的數組。
我需要通過從[2 * i,2 * j + 2]元素中減去[2 * i,2 * j]個元素和[2 * i,2 * j]形狀爲20 * 200的dz_theta_mat和dz_gamma_mat ]元素分別從[2 * i + 2,2 * j]個元素開始。
我的嘗試沒有給出列表所需的形狀。
我該如何修改它以獲得所需的結果?
print np.shape(z_mesh)
dz_gamma_mat = [z_mesh[2*i,2*j+2]-z_mesh[2*i,2*j] for i,j in itertools.product(range(20),range(199))]
print np.shape(fish_dz_gamma_mat)
dz_theta_mat = [z_mesh[2*i+2,2*j]-z_mesh[2*i,2*j] for i, j in itertools.product(range(19),range(200))]
print np.shape(fish_dz_theta_mat)
(41, 401)
(3980,)
(3800,)
列表中沒有形狀。當你說列表時,你的意思是數組嗎? –
是的,它是一個數組,對不起我的術語。我是python的新手。 –