numpy.ndarray.nbytes() 方法 | Python
numpy.ndarray.nbytes()
函数返回数组元素消耗的总字节数。
Syntax : numpy.ndarray.nbytes(arr)
Parameters :
arr : [array_like] Input array.
Return : [int] Total bytes consumed by the elements of the array.
代码#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