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

标签 python interpreter code-documentation

在 Python 解释器中:

有哪些方法可以了解我拥有的软件包?

>>> man sys
File "<stdin>", line 1
    man sys
      ^

语法错误:语法无效

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

更正:

>>> help(sys)
...

现在,如何在我的 sys.path 中查看所有可用的包?并查看它们的后续用法和文档。我知道我可以轻松下载 PDF,但所有这些东西都已经包含在内,我不想复制文件。

谢谢!

最佳答案

你可以查看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.

关于Python 解释器模式 - 有哪些探索 Python 模块及其用法的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15965260/

相关文章:

python - 如何读取文件夹中的文件名并按字母顺序和递增顺序访问它们?

python - 如何解压列表?

python - 沿第 3 维从 Numpy ndarray 中删除并提取最小值

python - eclipse ,PyDev "interpreter does not exist in filesystem"

php - 如何创建数学公式解释器

python - 是否可以有多个 PyPlot 窗口?还是我仅限于子图?

ruby - 自动将院子文档框架添加到现有的 Rails 遗留代码中

python - 使用 Python 脚本创建 MySQLdb 数据库

documentation - QTP/UFT 中的代码文档

java - Java 中类实现文档注释的正确位置