python - 如何列出模块中的所有功能?

标签 python reflection module inspect

我的系统上安装了一个 Python 模块,我希望能够查看其中可用的函数/类/方法。

我想在每一个上调用 help 函数。在 Ruby 中,我可以执行类似 ClassName.methods 的操作来获取该类上所有可用方法的列表。 Python中有类似的东西吗?

例如类似:

from somemodule import foo
print(foo.methods)  # or whatever is the correct method to call

最佳答案

您可以使用 dir(module) 查看所有可用的方法/属性。另请查看 PyDocs。

关于python - 如何列出模块中的所有功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/139180/

相关文章:

python - 转换python正则表达式

python - 如何在AWS Lambda上正常运行NaCL?

php - 使用 Reflection 类将精确数量的参数传递给 PHP 类构造函数

java - 处理嵌套类的整个类型名称

Python 错误 : PyThreadState_Get: no current thread after compiling an extension

module - Yii2 模块模型

python - 如何在 linux 终端中运行更新的 python 脚本

python pygame 输入控件

java - 使用反射动态调用正确的正确设置方法

Python 未检测到现有模块