__dict__

类有一个__dict__字典属性,保存了当前类的每一个成员,举例如下:

>>> class A:
    def __init__(self,value):
        self.value=value
    def printValue(self):
        print(self.value)

        
>>> A.__dict__
mappingproxy({'__module__': '__main__', '__init__': <function A.__init__ at 0x101162e18>, 'printValue': <function A.printValue at 0x1015af510>, '__dict__': <attribute '__dict__' of 'A' objects>, '__weakref__': <attribute '__weakref__' of 'A' objects>, '__doc__': None})

 

posted @ 2017-05-04 22:01  道高一尺  阅读(128)  评论(0编辑  收藏  举报