[Python] Array Attributes of Numpy lib

Attributes of numpy.ndarray:

import numpy as np 

def array():
    a = np.random.random((5,4))
    print(a.shape[0]) #number of rows, 5
    print(a.shape[1]) #number of columns, 4
    print(len(a.shape)) #2
    print(a.size) # 5*4=20
    print(a.dtype) #float64

if __name__ == "__main__":
    #gen_random() 
    array()   
原文地址:https://www.cnblogs.com/Answer1215/p/8053904.html