美文网首页我爱编程
Numpy 数组的遍历

Numpy 数组的遍历

作者: 小螳螂 | 来源:发表于2017-08-30 16:52 被阅读0次

    使用 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 1]
     [2 3]]
    <numpy.flatiter object at 0x10082c000>
    0
    1
    2
    3
    

    相关文章

      网友评论

        本文标题:Numpy 数组的遍历

        本文链接:https://www.haomeiwen.com/subject/kohxjxtx.html