我想知道是否有专门用于 Python 的像“man.py”这样的 CLI?
前任,
man.py os.system
> system(command) -> exit_status
>
> Execute the command (a string) in a subshell.
我想知道是否有专门用于 Python 的像“man.py”这样的 CLI?
前任,
man.py os.system
> system(command) -> exit_status
>
> Execute the command (a string) in a subshell.
pydoc 模块提供了它:
$ python -m pydoc os.system
Help on built-in function system in os:
os.system = system(...)
system(command) -> exit_status
Execute the command (a string) in a subshell.
$
最简单的方法是pydoc function
在 shell 上使用,function
可以是内置函数的名称,也可以是模块中函数的限定名称 ( module.function
):
> PAGER=cat pydoc urllib.urlencode
[adrian@hades:~]> PAGER=cat pydoc urllib.urlencode
Help on function urlencode in urllib:
urllib.urlencode = urlencode(query, doseq=0)
Encode a sequence of two-element tuples or dictionary into a URL query string.
...
(PAGER=cat
仅用于在此处复制和粘贴)
使用 IPython 时,您可以使用function?
查看文档字符串function
或function??
更详细的视图,其中包括用 python 编写的函数的完整源代码。
在普通的 python shell 中,您可以使用help(function)
它。但是,在我看来,IPython 方式更舒服。