Linux command
pydoc 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
View documentation
pydoc [module]
View documentation
pydoc [module.ClassName]
Search module synopses
pydoc -k [keyword]
Start a local documentation HTTP server
pydoc -p [8080]
Start server and open
pydoc -b
Write HTML documentation
pydoc -w [module]
说明
pydoc is Python's built-in documentation tool that displays module documentation generated from docstrings and introspection. It can show documentation for modules, classes, functions, and keywords in the terminal, search across all installed modules with -k, or generate static HTML files with -w. The -p flag starts a local HTTP documentation server that provides a browsable interface to all installed Python modules, and -b opens this server automatically in the default web browser. pydoc is part of the Python standard library and provides the same functionality as the interactive help() function. The PAGER environment variable controls which program is used for terminal display. The BROWSER environment variable controls which browser is used with -b.
参数
- -k _keyword_
- Search synopsis lines of all available modules for keyword.
- -p _port_
- Start HTTP documentation server on the given port.
- -b
- Start HTTP server and open a web browser to its page.
- -w _name_
- Write HTML documentation for the module to a file in the current directory.
- -n _host_
- Hostname for the HTTP server (default: localhost). Python 3.11+.
FAQ
What is the pydoc command used for?
pydoc is Python's built-in documentation tool that displays module documentation generated from docstrings and introspection. It can show documentation for modules, classes, functions, and keywords in the terminal, search across all installed modules with -k, or generate static HTML files with -w. The -p flag starts a local HTTP documentation server that provides a browsable interface to all installed Python modules, and -b opens this server automatically in the default web browser. pydoc is part of the Python standard library and provides the same functionality as the interactive help() function. The PAGER environment variable controls which program is used for terminal display. The BROWSER environment variable controls which browser is used with -b.
How do I run a basic pydoc example?
Run `pydoc [module]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -k _keyword_ do in pydoc?
Search synopsis lines of all available modules for keyword.