Two ways for python to view third-party package module documents

1. Generate a temporary URL (recommended)

Enter the command in the dos window: python -m pydoc -p 0, the machine will randomly generate a port number (you can also specify the port number, pay attention to port conflicts), enter b to open directly, or copy the address to open it in the browser.
insert image description here

insert image description here
ctrl+f The module name to be queried.

2. Through the built-in function help()+dir()

help(): Query the document information of variables or functions under the package or package module, refer to https://www.python51.com/jc/74498.html

dir(): List all variables and functions under the package module, refer to http://www.coolpython.net/method_topic/builtin-func/dir.html

For example, if you want to know which variables and functions are under the re module, you can

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']

Want to see the documentation of the "compile" function in detail

help(re.compile)

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

Guess you like

Origin blog.csdn.net/atwdy/article/details/129905616