Python help() 函数用于获取与调用过程中传递的对象相关的帮助。它接受一个可选参数并返回帮助信息。如果没有给出参数,它会显示 Python 帮助控制台。它内部调用python的帮助函数。
签名
help(object)
参数
object:它可以是我们想要获得帮助的任何对象。
返回
它返回对象的信息。
让我们看一些 help() 函数的例子来理解它的函数。
Python help() 函数示例 1
# Python help() function example
# Calling function
info = help() # No argument
# Displaying result
print(info)
输出:
Welcome to Python 3.5's help utility!
Python help() 函数示例2
# Python help() function example
# Calling function
info = help(1) # integer value
# Displaying result
print(info)
输出:
Help on int object: class int(object) | int(x=0) -> integer | int(x, base=10) -> integer | | Methods defined here: | | __abs__(self, /) | abs(self) | | __add__(self, value, /) | Return self+value. | | __and__(self, value, /) | Return self&value.;
Python help() 函数示例3
如果对象是一个列表,它会打开列表模块和它的类。查看输出。
# Python help() function example
# Calling function
info = help(list) # integer value
# Displaying result
print(info)
输出:
Help on class list in module builtins: class list(object) | list() -> new empty list | list(iterable) -> new list initialized from iterable's items | | Methods defined here: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __delitem__(self, key, /) | Delete self[key].
Python help() 函数示例 4
如果没有帮助或信息,它会向控制台显示一条消息并返回 None。
# Python help() function example
# Calling function
info = help("Javatpoint") # integer value
# Displaying result
print(info)
输出:
No Python documentation found for 'Javatpoint'. Use help() to get the interactive help utility. Use help(str) for help on the str class. None
相关用法
- 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 hashlib.shake_128()用法及代码示例
- Python hashlib.sha3_384()用法及代码示例
- Python numpy.less()用法及代码示例
- Python Sympy Permutation.list()用法及代码示例
- Python Matplotlib.figure.Figure.subplots_adjust()用法及代码示例
- Python numpy.tril()用法及代码示例
- Python Matplotlib.pyplot.matshow()用法及代码示例
注:本文由纯净天空筛选整理自 Python help() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。