numpy设置输出精度
使用set_printoptions设置输出的精度import numpy as npx=np.random.random(10)print(x)# [ 0.078378210.480021080.412741160.829934140.776103520.1023732#0.513030980.46171830.334872070.71162095...
·
使用set_printoptions设置输出的精度
import numpy as np
x=np.random.random(10)
print(x)
# [ 0.07837821 0.48002108 0.41274116 0.82993414 0.77610352 0.1023732
# 0.51303098 0.4617183 0.33487207 0.71162095]
np.set_printoptions(precision=3)
print(x)
# [ 0.078 0.48 0.413 0.83 0.776 0.102 0.513 0.462 0.335 0.712]
抑制使用对小数的科学记数法
y=np.array([1.5e-10,1.5,1500])
print(y)
# [ 1.500e-10 1.500e+00 1.500e+03]
np.set_printoptions(suppress=True)
print(y)
# [ 0. 1.5 1500. ]
更多推荐

所有评论(0)