Python numpy.ndarray.nbytes()
numpy.ndarray.nbytes()函数返回数组元素所消耗的总字节数。
语法: numpy.ndarray.nbytes(arr)
参数 :
arr : [array_like] 输入阵列。
返回: [int] 数组元素所消耗的总字节数。
代码#1:
# Python program explaining
# numpy.ndarray.nbytes() function
# importing numpy as geek
import numpy as geek
arr = geek.zeros((1, 2, 3), dtype = geek.complex128)
gfg = arr.nbytes
print (gfg)
输出 :
96
代码#2:
# Python program explaining
# numpy.ndarray.nbytes() function
# importing numpy as geek
import numpy as geek
arr = geek.random.rand(10000, 50)
gfg = arr.nbytes
print (gfg)
输出 :
4000000