您可以使用来遍历数组中的值,numpy.ndenumerate
以获取数组中值的索引。
使用上面的文档:
A = np.array([[1,2,3],[4,5,6],[7,8,9]])
for index, values in np.ndenumerate(A):
print(index, values) # operate here
用索引迭代numpy(相当于python枚举的numpy)
您可以使用来遍历数组中的值,numpy.ndenumerate
以获取数组中值的索引。
使用上面的文档:
A = np.array([[1,2,3],[4,5,6],[7,8,9]])
for index, values in np.ndenumerate(A):
print(index, values) # operate here