2012-06-09 36 views
8

我想知道是否有像'man.py'专用于Python的CLI?python有没有'男人'?

前,

man.py os.system 
> system(command) -> exit_status 
> 
> Execute the command (a string) in a subshell. 

回答

10

使用在壳pydoc function,最简单的方法与function是一个内置的名称或功能的一个模块中的合格域名(module.function):

> PAGER=cat pydoc urllib.urlencode 
[[email protected]:~]> 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只用来使它复制到这里& pastable)

使用IPython时,可以使用function?来查看functionfunction??的文档字符串以获取更详细的视图,其中包含用python编写的函数的完整源代码。

在普通的python shell中,你可以使用help(function)来做到这一点。但在我看来,IPython的方式更加舒适。

+0

1为提IPython的 – Levon

+1

或'function'其等于''功能是pydoc – Vidul

14

的是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. 
$ 
+0

是在/ usr/bin中。 –