Numpy操作结果像列表一样打印而不是numpy数组

时间:2019-04-03 15:15:33

标签: python numpy

我想使用NumPy包在Python中垂直连接两个数组,但是我需要一个不同的输出。

我有两个列表

a=[1,2,3]
b=[7,8,9]

我写这是为了解决问题

a1 = np.array(a)
a2 = np.array(b)
np.vstack((a1,a2))

我的输出是

[[1 2 3]
 [7 8 9]]

但是我需要这样的输出

array([[1, 2, 3],
[7, 8, 9]])

我想念什么?谢谢

1 个答案:

答案 0 :(得分:0)

您的结果正确是x = 0 cb = 25000 a = 50000 unpaid = cb-x # unpaid balance inc = unpaid*(a/12) # increment def mintha (x): ''' x is the minimum payable per month to pay off debt (round to tenth) ''' totalPay = unpaid + inc # total credit balance, including the # interests if (12*x - totalPay) >= 0: return round(x) else: totalPay = unpaid + inc return round(totalPay) print(mintha(3000)) #Output: 104191667 。要查看此内容,您需要其repr而不是打印输出:

np.ndarray