【发布时间】:2015-10-13 10:30:16
【问题描述】:
import numpy as np
S = np.array(l)
for i in range(1, l):
random_int = randint(0, 1)
np.append(S, random_int)
我创建了一个大小为 l 的 numpy 数组,并用零和一填充它。假设我想打印数组的第三个元素。我怎么做?
如果我输入
print(S[2])
我收到以下错误:
IndexError: too many indices for array
【问题讨论】:
标签: python arrays python-3.x numpy