【发布时间】:2016-12-10 21:35:18
【问题描述】:
我正在使用 Python 2.7。从以前的帖子中,我正在学习 Python,并且我已经从数组转移,现在我正在研究循环。我也在尝试使用数组进行操作。
A1 = np.random.random_integers(35, size=(10.,5.))
A = np.array(A1)
B1 = np.random.random_integers(68, size=(10.,5.))
B = np.array(B1)
D = np.zeros(10,5) #array has 10 rows and 5 columns filled with zeros to give me the array size I want
for j in range (1,5):
for k in range (1,5):
D[j,k] = 0
for el in range (1,10):
D[j,k] = D[j,k] + A[j] * B[k]
我得到的错误是:使用序列设置数组元素
我的格式不正确吗?
【问题讨论】:
标签: arrays python-2.7 loops for-loop