Python解释器模式 - 有哪些方法可以探索Python的模块及其用法

Jac*_*Chi 3 python interpreter code-documentation

在Python解释器中:

有什么方法可以了解我的包装?

>>> man sys
File "<stdin>", line 1
    man sys
      ^
Run Code Online (Sandbox Code Playgroud)

SyntaxError:语法无效

>>> sys --help
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: bad operand type for unary -: '_Helper'
Run Code Online (Sandbox Code Playgroud)

更正:

>>> help(sys)
...
Run Code Online (Sandbox Code Playgroud)

现在,我如何在sys.path上看到我可以使用的所有软件包?并查看其后续使用和文档.我知道我可以轻松下载PDF,但所有这些东西已经出炉了,我不想复制文件.

谢谢!

kha*_*hik 7

您可以查看help("modules"),它显示可用模块的列表.探索特定的模块/类/功能使用dir__doc__:

>>> import sys
>>> sys.__doc__
"This module ..."

>>> dir(sys)
[..., 'setprofile', ...]

>>> print(sys.setprofile.__doc__)
setprofile(function)

Set the profiling function.  It will be called on each function call
and return.  See the profiler chapter in the library manual.
Run Code Online (Sandbox Code Playgroud)