我在我的系统上安装了一个python模块,我希望能够看到它中有哪些函数/类/方法.
我想在每一个上调用doc函数.在ruby中,我可以执行类似ClassName.methods的操作,以获取该类上可用的所有方法的列表.python中有类似的东西吗?
例如.就像是:
from somemodule import foo
print foo.methods # or whatever is the correct method to call
当需要有关类型的信息时,您可以使用:
my_list = []
dir(my_list)
得到:
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
要么:
dir(my_list)[36:]
得到:
['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
现在,在Python的文档中可以找到有关这些函数的信息,但我想在终端/命令行中获取有关这些函数的信息.该怎么做?