我以下面显示的方式创建了一个数组; 代表3对坐标.我的问题是我似乎无法找到数组中特定坐标对的索引.
import numpy as np
R = np.random.uniform(size=(3,2))
R
Out[5]:
array([[ 0.57150157, 0.46611662],
[ 0.37897719, 0.77653461],
[ 0.73994281, 0.7816987 ]])
R.index([ 0.57150157, 0.46611662])
Run Code Online (Sandbox Code Playgroud)
返回以下内容:
AttributeError: 'numpy.ndarray' object has no attribute 'index'
Run Code Online (Sandbox Code Playgroud)
我试图这样做的原因是我可以在一个for循环中扩展一个带有坐标对的索引的列表.
例如
v = []
for A in R:
v.append(R.index(A))
Run Code Online (Sandbox Code Playgroud)
我只是不确定为什么索引功能不起作用,似乎无法找到解决方法.
我是编程的新手,请原谅我,如果这看起来像废话.