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

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

numpy.ndarray.nbytes() 方法 | Python

numpy.ndarray.nbytes()函数返回数组元素消耗的总字节数。

代码#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