强制numpy数组打印到精确的精度

时间:2019-03-26 01:42:16

标签: python arrays numpy

假设我有2个numpy数组:

import numpy as np
a = np.array([1, 2,      3,      4     ], dtype='float64')
b = np.array([1, 2.0034, 4,      5.4322], dtype='float64')
c = np.array([1, 2,      3.1234, 5.321 ], dtype='float64')
print('a is : ', a)
print('b is : ', b)
print('c is : ', c)

这将打印为:

a is [1. 2. 3. 4.]
b is [1.     2.0034 4.     5.4322]
c is [1.     2.     3.1234 5.321 ]
# How nicely the bottom two arrays are aligned! Because they have equal precessions.

但是我想将它们全部对齐打印。如下所示:

a is [1.     2.     3.     4.]
b is [1.     2.0034 4.     5.4322]
c is [1.     2.     3.1234 5.321 ]

0 个答案:

没有答案