Python numpy.ndarray.itemsize()
numpy.ndarray.itemsize()函数返回一个数组元素的长度,单位是字节。
语法: numpy.ndarray.itemsize(arr)
参数 :
arr : [array_like] 输入阵列。
返回: [int] 一个数组元素的长度,以字节为单位
代码#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