如何列出Python模块中的所有功能? [英] How to list all functions in a Python module?
问题描述
我的系统上安装了一个python模块,我希望能够看到其中可用的功能/类/方法.
I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it.
我想在每个函数上调用doc函数.在ruby中,我可以执行类似ClassName.methods之类的操作来获取该类上所有可用方法的列表. python中有类似的东西吗?
I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods available on that class. Is there something similar in python?
例如像这样:
from somemodule import foo
print foo.methods # or whatever is the correct method to call
推荐答案
inspect
模块.另请参见 pydoc
模块,交互式解释器中的help()
函数.和pydoc
命令行工具将生成您要使用的文档.您可以给他们提供您想查看其文档的课程.他们还可以生成例如HTML输出并将其写入磁盘.
The inspect
module. Also see the pydoc
module, the help()
function in the interactive interpreter and the pydoc
command-line tool which generates the documentation you are after. You can just give them the class you wish to see the documentation of. They can also generate, for instance, HTML output and write it to disk.
这篇关于如何列出Python模块中的所有功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!