python查看第三方包模块文档的两种方式
本机会随机生成一个端口号(也可以指定端口号,注意端口冲突),输入b直接打开,或者复制地址浏览器中打开查看。ctrl+f 要查询的模块名。
·
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.

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。
更多推荐
所有评论(0)