Python 3 内置函数 - help()
函数
0. help()
函数
用于查看函数或模块用途的详细说明。
1. 使用方法
>>> help(help)
# output:
Help on _Helper in module _sitebuiltins object:
class _Helper(builtins.object)
| Define the builtin 'help'.
|
| This is a wrapper around pydoc.help that provides a helpful message
| when 'help' is typed at the Python interactive prompt.
|
| Calling help() at the Python prompt starts an interactive help session.
| Calling help(thing) prints help for the python object 'thing'.
|
| Methods defined here:
|
| __call__(self, *args, **kwds)
| Call self as a function.
|
| __repr__(self)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
3. 使用示例
如想获得 abs
的使用帮助,可以:
abs()
函数返回数字的绝对值。
>>> help(abs)
# output:
Help on built-in function abs in module builtins:
abs(x, /)
Return the absolute value of the argument.