Skip to content

Latest commit

 

History

History
28 lines (28 loc) · 619 Bytes

ch05_数组属性.md

File metadata and controls

28 lines (28 loc) · 619 Bytes

ndim:数组的维数(数组的轴数)

# coding=utf-8
import numpy as np
arr1=np.arange(12).reshape(2,3,2)
print arr1.ndim  #输出3

size:数组元素的个数

# coding=utf-8
import numpy as np
arr1=np.arange(12).reshape(2,3,2)
print arr1.size  #输出12

itemsize:数组中元素在内存中占的字节数

# coding=utf-8
import numpy as np
arr1=np.arange(12).reshape(2,3,2)
print arr1.itemsize  #输出4

nbytes:整个数组占的存储空间

# coding=utf-8
import numpy as np
arr1=np.arange(12).reshape(2,3,2)
print arr1.nbytes  #输出48