我已经按照下面的方式创建了一个数组,它表示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])
以下内容将被返回:
AttributeError: 'numpy.ndarray' object has no attribute 'index'
我正在尝试这样做的原因是为了在for循环中使用坐标对的索引来扩展列表。
例如:
v = []
for A in R:
v.append(R.index(A))
我不确定为什么索引函数不起作用,也找不到解决方法。
我是新手程序员,请见谅如果这听起来有些无意义。