在 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/