NumPy参考 >数组对象 >标准数组子类 > numpy.ndenumerate
numpy.
ndenumerate
多维索引迭代器。
返回一个迭代器,生成数组坐标和值对。
输入数组。
也可以看看
ndindex, flatiter
ndindex
flatiter
例子
>>> a = np.array([[1, 2], [3, 4]]) >>> for index, x in np.ndenumerate(a): ... print(index, x) (0, 0) 1 (0, 1) 2 (1, 0) 3 (1, 1) 4
方法
next(自)
next
标准迭代器方法,返回索引元组和数组值。