(1)查看python的模块和函数的帮助文档和方法
>>> help() Welcome to Python 3.6's help utility! If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://docs.python.org/3.6/tutorial/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, symbols, or topics, type "modules", "keywords", "symbols", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose name or summary contain a given string such as "spam", type "modules spam".
help> modules #列出当前python所有可用的模块
Please wait a moment while I gather a list of all available modules...
查看特定模块的信息
使用help(module_name)
时首先需要import该模块,有些教程中不进行导入而在模块名中加入引号help('module_name')
,这种方法可能会带来问题
大家可以用math模块测试,建议使用先导入再使用help()
函数查询。
查看内建模块
>>> import sys
>>> sys.builtin_module_names
('_ast', '_bisect', '_codecs', '_codecs_cn', '_codecs_hk', ... 'zlib')
>>>
查看模块下的所有函数
>>> dir(math)
['__doc__', '__loader__', '__name__',...]
>>>
查看模块下特定的函数信息
>>> import math
>>> help(math.sin)
Help on built-in function sin in module math:
sin(...)
sin(x)
Return the sine of x (measured in radians).
>>>
>>> print(print.__doc__)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.