numpy.who(vardict=None) 函數打印給定字典中的 Numpy ndarray。如果沒有傳入字典或 vardict 為 None,則在 globals() 字典中打印 NumPy 數組。
參數:
vardict:可能包含 ndarray 的字典。默認為 globals()。
返回值:
out:空
注意:它打印出 vardict 中存在的所有 ndarray 的名稱、形狀、字節和類型,但不返回任何內容。
範例1:在此示例中,字典作為參數傳遞給 numpy.who() 函數。
Python3
# import the numpy module as np
import numpy as np
# dictionary containing numpy ndarrays
gfg = {'arr_1':np.arange(3), 'arr_2':np.arange(6),
'name':'some text', 'number':34523}
# passing the dict as argument
np.who(gfg)
輸出:
範例2:在此示例中,沒有參數傳遞給 numpy.who() 函數,因此它在 globals() 字典中打印 ndarray。
Python3
# import the numpy module as np
import numpy as np
# creating numpy ndarrays
x = np.arange(20)
y = np.ones(5)
z = np.zeros(10)
# function called without passing any argument
np.who()
輸出:
相關用法
- Python Wand function()用法及代碼示例
- Python Numbers choice()用法及代碼示例
- Python ord()用法及代碼示例
- Python sum()用法及代碼示例
- Python round()用法及代碼示例
- Python id()用法及代碼示例
- Python vars()用法及代碼示例
注:本文由純淨天空篩選整理自mohanrajnambe大神的英文原創作品 numpy.who() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。