python中每一个对象或者对象的方法都有可以使用三种方式查看相关的使用方法和帮助文档。
class SampleClass(object):
"""Summary of class here.
Longer class information....
Longer class information....
Attributes:
likes_spam: A boolean indicating if we like SPAM or not.
eggs: An integer count of the eggs we have laid.
"""
def __init__(self, likes_spam=False):
"""Inits SampleClass with blah."""
self.likes_spam = likes_spam
self.eggs = 0
def public_method(self):
"""Performs operation blah."""
if __name__ == '__main__':
# a = '5' # xxxxx
print(SampleClass.__doc__)
print(dir(SampleClass))
print(help(SampleClass))
print(dir(SampleClass.public_method))
print(help(SampleClass.public_method))
直接调用对象或者方法的doc属性,或者使用dir()或者使用help()来查看就可以了。