不打印 2D numpy 数组,显示浮点值

Printing a 2D numpy array not, showing float values

我正在尝试显示一个 2D numpy 浮点数组,但每当我打印时,该数组只打印为整数。有什么方法可以显示完整的浮点数吗?

我知道我可以去掉 np.array 但我希望数组垂直显示。

import numpy as np

MPass = 100
MPL = 25
ME = 120
Mwob = ME + MPL + MPass
rho = 1.225
g = 9.8
R = 0.3
pi = 3.14159
A = pi * R** 2
Aduct = 1.5 * A
Wwob = Mwob * g
Mb = 300
e = 400
Nfan = 12
w, h = 4, 101
X = np.array([[0 for x in range(w)] for y in range(h)])
x = 0

while Mb < 401:
    Wb = Mb * g
    Wt = Wb + Wwob
    Mt = Mb + Mwob
    Pav = e * Mb
    Pav_fan = Pav/Nfan
    vi = (Pav_fan/(2*rho*Aduct))**(1/3)
    Tmax_fan = 2 * rho * Aduct * vi**2
    Ttmax = Tmax_fan * Nfan
    Fnet = Ttmax - Wt
    X[x][0] = Mb
    X[x][1] = Fnet
    X[x][2] = Mt
    a = Fnet/Mt
    if a < 0:
        t = 0
    else:
        t = ((2*762)/a)**0.5
    X[x][3] = t
    x = x + 1
    Mb = Mb + 1

print(X)

改变

X = np.array([[0 for x in range(w)] for y in range(h)])

X = np.array([[0 for x in range(w)] for y in range(h)], dtype=float)

希望对您有所帮助! :D

您可以尝试只投射浮点数:print(np.array(X,dtype=float))