python创建多维数组的3种方式:

发布时间:2019-09-08 09:11:16编辑:auto阅读(2110)

    python创建多维数组的3种方式:

    #coding=utf-8
    import numpy as np
    #1
    image =[[(col+1)*(row+1) for col in range(5)] for row in range(3)]
    a = np.array(image)
    print(a)
    
    #2
    new_image =np.zeros((3,5))
    
    #3
    b = np.arange(12).reshape(3,4)
    print(b)
    

关键字