如果我正确理解你的问题 - 连接不是你正在寻找。连结如你所见:加入along an axis。
如果你想有一个成为另一个值的空矩阵,你可以做到以下几点:
import numpy as np
a = np.zeros([2,2])
b = np.array([[1,2],[3,4]])
my_array = a + b
- 或 -
import numpy as np
my_array = np.zeros([2,2]) # you can use empty here instead in this case.
my_array[0,0] = float(input('Enter first value: ')) # However you get your data to put them into the arrays.
但是,我猜测,是不是你真正想要的,因为你可以使用my_array = b。如果您使用更多信息编辑您的问题,我可能会提供更多帮助。
如果你担心增加随着时间的推移您的数组值...
import numpy as np
a = np.zeros([2,2])
my_array = b # b is some other 2x2 matrix
''' Do stuff '''
new_b # New array has appeared
my_array = new_b # update your array to these new values. values will not add.
# Note: if you make changes to my_array those changes will carry onto new_b. To avoid this at the cost of some memory:
my_array = np.copy(new_b)