numpy.ndarray.itemsize() 方法 | Python
numpy.ndarray.itemsize()
函数返回一个数组元素的长度(以字节为单位)。
Syntax : numpy.ndarray.itemsize(arr)
Parameters :
arr : [array_like] Input array.
Return : [int] The length of one array element in bytes
代码#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