【发布时间】:2015-12-09 14:19:59
【问题描述】:
我对 python 还很陌生,但这个例子对我不起作用。我相信它是为了索引 x,但我不是 100% 确定。
import numpy as np
y = np.array([0,1,2,3,4,5,2,4,1,9])
x = np.array(['e','l','t','d','m','f','c','j','x','a'])
print
print
print "Y"
print type(y)
print y
print
print
print "X"
print type(x)
print x
print
print
result = x[0, y]
我得到的确切错误是
Traceback (most recent call last):
File "test.py", line 20, in <module>
result = x[0, y]
IndexError: too many indices for array
【问题讨论】:
-
您的预期结果是什么?
result应该是什么样的?