python中每一個(gè)對(duì)象或者對(duì)象的方法都有可以使用三種方式查看相關(guān)的使用方法和幫助文檔。
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))
直接調(diào)用對(duì)象或者方法的doc屬性,或者使用dir()或者使用help()來(lái)查看就可以了。