我有一个嵌套的 Python 列表,如下所示:
my_list = [[3.74, 5162, 13683628846.64, 12783387559.86, 1.81], [9.55, 116, 189688622.37, 260332262.0, 1.97], [2.2, 768, 6004865.13, 5759960.98, 1.21], [3.74, 4062, 3263822121.39, 3066869087.9, 1.93], [1.91, 474, 44555062.72, 44555062.72, 0.41], [5.8, 5006, 8254968918.1, 7446788272.74, 3.25], [4.5, 7887, 30078971595.46, 27814989471.31, 2.18], [7.03, 116, 66252511.46, 81109291.0, 1.56], [6.52, 116, 47674230.76, 57686991.0, 1.43], [1.85, 623, 3002631.96, 2899484.08, 0.64], [13.76, 1227, 1737874137.5, 1446511574.32, 4.32], [13.76, 1227, 1737874137.5, 1446511574.32, 4.32]]
然后我导入 Numpy,并将打印选项设置为(suppress=True). 当我创建一个数组时:
(suppress=True)
my_array = numpy.array(my_list)
我不能一辈子压制科学记数法:
[[ 3.74000000e+00 5.16200000e+03 1.36836288e+10 1.27833876e+10 1.81000000e+00] [ 9.55000000e+00 1.16000000e+02 1.89688622e+08 2.60332262e+08 1.97000000e+00] [ 2.20000000e+00 7.68000000e+02 6.00486513e+06 5.75996098e+06 1.21000000e+00] [ 3.74000000e+00 4.06200000e+03 3.26382212e+09 3.06686909e+09 1.93000000e+00] [ 1.91000000e+00 4.74000000e+02 4.45550627e+07 4.45550627e+07 4.10000000e-01] [ 5.80000000e+00 5.00600000e+03 8.25496892e+09 7.44678827e+09 3.25000000e+00] [ 4.50000000e+00 7.88700000e+03 3.00789716e+10 2.78149895e+10 2.18000000e+00] [ 7.03000000e+00 1.16000000e+02 6.62525115e+07 8.11092910e+07 1.56000000e+00] [ 6.52000000e+00 1.16000000e+02 4.76742308e+07 5.76869910e+07 1.43000000e+00] [ 1.85000000e+00 6.23000000e+02 3.00263196e+06 2.89948408e+06 6.40000000e-01] [ 1.37600000e+01 1.22700000e+03 1.73787414e+09 1.44651157e+09 4.32000000e+00] [ 1.37600000e+01 1.22700000e+03 1.73787414e+09 1.44651157e+09 4.32000000e+00]]
如果我直接创建一个简单的 numpy 数组:
new_array = numpy.array([1.5, 4.65, 7.845])
我没有问题,它打印如下:
[ 1.5 4.65 7.845]
有谁知道我的问题是什么?
这就是你需要的:
np.set_printoptions(suppress=True)
这是文档。