2021-02-24
阅读量:
434
Python Numpy数组遍历的两种方法
直接遍历
[a, b] = test.shape
for i in range(a-1):
for j in range(b-1):
print(b[i][j])
print(type(b))
2.使用 flat 属性 返回 numpy.flatiter对象(唯一获取flatiter的方式)
a = np.arange(4).reshape(2,2)
print(a)
f = a.flat
print(f)
for item in f:
print(item)






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论