[Python] Array Attributes of Numpy lib

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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()   

 

以上是关于[Python] Array Attributes of Numpy lib的主要内容,如果未能解决你的问题,请参考以下文章