numpy.ndarray.size()函數返回數組中的元素數。它等於np.prod(a.shape),即數組尺寸的乘積。
用法: numpy.ndarray.size(arr)
參數:
arr :[數組]輸入數組。
Return :[int]數組中元素的數量。
代碼1:
# Python program explaining
# numpy.ndarray.size() function
# importing numpy as geek
import numpy as geek
arr = geek.zeros((3, 4, 2), dtype = geek.complex128)
gfg = arr.size
print (gfg)
輸出:
24
代碼2:
# Python program explaining
# numpy.ndarray.size() function
# importing numpy as geek
import numpy as geek
arr = geek.zeros((3, 4, 2), dtype = geek.complex128)
gfg = geek.prod(arr.shape)
print (gfg)
輸出:
24
相關用法
- Python set()用法及代碼示例
- Python next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python PyTorch div()用法及代碼示例
- Python PIL getpalette()用法及代碼示例
- Python Pytorch eye()用法及代碼示例
- Python os.chdir()用法及代碼示例
- Python Numpy np.fft()用法及代碼示例
- Python isinstance()用法及代碼示例
- Python PIL putdata()用法及代碼示例
- Python numpy.ma.ids()用法及代碼示例
- Python os.utime()用法及代碼示例
- Python os.kill()用法及代碼示例
- Python PIL GaussianBlur()用法及代碼示例
- Python PIL getcolors()用法及代碼示例
- Python os.WIFSTOPPED()用法及代碼示例
- Python os.WIFCONTINUED()用法及代碼示例
注:本文由純淨天空篩選整理自sanjoy_62大神的英文原創作品 numpy.ndarray.size() method | Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。