python查看第三方包模块文档的两种方式

1.生成临时网址方式(推荐)

dos窗口输入命令:python -m pydoc -p 0,本机会随机生成一个端口号(也可以指定端口号,注意端口冲突),输入b直接打开,或者复制地址浏览器中打开查看。
在这里插入图片描述

在这里插入图片描述
ctrl+f 要查询的模块名。

2.通过内置函数help()+dir()

help(): 查询包或包模块下变量或函数的文档信息,参考 https://www.python51.com/jc/74498.html

dir():列出包模块下所有的变量和函数,参考 http://www.coolpython.net/method_topic/builtin-func/dir.html

例如想知道re模块下有哪些变量和函数,可以

import re
print(dir(re))

# ['A', 'ASCII', 'DEBUG', 'DOTALL', 'I', 'IGNORECASE', 'L', 'LOCALE', 'M', 'MULTILINE', 'RegexFlag', 'S', 'Scanner', 'T', 'TEMPLATE', 'U', 'UNICODE', 'VERBOSE', 'X', '_MAXCACHE', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__version__', '_alphanum_bytes', '_alphanum_str', '_cache', '_compile', '_compile_repl', '_expand', '_locale', '_pattern_type', '_pickle', '_subx', 'compile', 'copyreg', 'enum', 'error', 'escape', 'findall', 'finditer', 'fullmatch', 'functools', 'match', 'purge', 'search', 'split', 'sre_compile', 'sre_parse', 'sub', 'subn', 'template']

想具体查看“compile”这个函数的文档说明

help(re.compile)

# Help on function compile in module re:
# 
# compile(pattern, flags=0)
#     Compile a regular expression pattern, returning a pattern object.

猜你喜欢

转载自blog.csdn.net/atwdy/article/details/129905616
今日推荐