📜  numpy.ndarray.itemsize() 方法 | Python

📅  最后修改于: 2022-05-13 01:55:22.634000             🧑  作者: Mango

numpy.ndarray.itemsize() 方法 | Python

numpy.ndarray.itemsize()函数返回一个数组元素的长度(以字节为单位)。

代码#1:

# Python program explaining
# numpy.ndarray.itemsize() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.array([1, 2, 3, 4], dtype = geek.float64)
  
gfg = arr.itemsize
  
print (gfg)

输出 :

8


代码#2:

# Python program explaining
# numpy.ndarray.itemsize() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.array([1, 2, 3, 4],  dtype = geek.complex128)
  
gfg = arr.itemsize
  
print (gfg)

输出 :

16