help() 方法調用內置的 Python 幫助係統。
用法:
help(object)
參數:
help()
方法最多采用一個參數。
- object(可選) - 你想生成給定的幫助
object
help() 如何在 Python 中工作?
help()
方法用於交互使用。當您需要幫助編寫 Python 程序並使用 Python modules 時,建議在您的解釋器中嘗試。
Note: object
傳遞給 help()
(不是字符串)
在 Python shell 上試試這些。
>>> help(list)
>>> help(dict)
>>> help(print)
>>> help([1, 2, 3])
如果字符串作為參數傳遞,則模塊、函數、類、方法、關鍵字或文檔主題的名稱以及幫助頁麵將被打印。
注意:字符串作為參數傳遞給help()
如果 string
作為參數傳遞,則將給定的字符串查找為模塊、函數、類、方法、關鍵字或文檔主題的名稱,並打印幫助頁麵。
在 Python shell 上試試這些。
>>> help('random thing')
>>> help('print')
>>> help('def')
>>> from math import *
help('math.pow')
注意:沒有參數傳遞給help()
如果未傳遞任何參數,則 Python 的幫助實用程序(交互式幫助係統)會在控製台上啟動。
>>> help()
然後,您可以輸入主題名稱以獲取有關編寫 Python 程序和使用 Python 模塊的幫助。例如:
help> True
help> 'print'
help > print
要退出幫助實用程序並返回解釋器,您需要輸入quit
並按回車鍵。
help > quit
相關用法
- Python hex()用法及代碼示例
- Python hashlib.sha3_256()用法及代碼示例
- Python hashlib.sha3_512()用法及代碼示例
- Python hashlib.blake2s()用法及代碼示例
- Python hashlib.blake2b()用法及代碼示例
- Python hasattr()用法及代碼示例
- Python html.escape()用法及代碼示例
- Python statistics harmonic_mean()用法及代碼示例
- Python html.unescape()用法及代碼示例
- Python math hypot()用法及代碼示例
- Python hash()用法及代碼示例
- Python hashlib.sha3_224()用法及代碼示例
- Python hashlib.shake_256()用法及代碼示例
- Python OpenCV haveImageReader()用法及代碼示例
- Python hashlib.shake_128()用法及代碼示例
- Python hashlib.sha3_384()用法及代碼示例
- Python torch.distributed.rpc.rpc_async用法及代碼示例
- Python torch.nn.InstanceNorm3d用法及代碼示例
- Python pandas.arrays.IntervalArray.is_empty用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
注:本文由純淨天空篩選整理自 Python help()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。