标签:iter tin html color arrays out long get int
1. Using for-loop
Iterate along row axis:
1 import numpy as np 2 x=np.array([[1,2,3],[4,5,6]]) 3 for i in x: 4 print(x)
Output:
[1 2 3]
[4 5 6]
2. Using ndenumerate object
for index, i in np.ndenumerate(x):
print(index,i)
Output:
(0, 0) 1
(0, 1) 2
(0, 2) 3
(1, 0) 4
(1, 1) 5
(1, 2) 6
3. Using nditer object
See: https://docs.scipy.org/doc/numpy-1.15.0/reference/arrays.nditer.html
[Python Cookbook] Numpy: Iterating Over Arrays
标签:iter tin html color arrays out long get int
原文地址:https://www.cnblogs.com/sherrydatascience/p/10206788.html