面向对象5 类特殊成员之 dict 自定义form框架时会用到
class Foo: def __init__(self): self.name = "TOM" def haha(self): pass r = Foo() print(r.__dict__) 输出对象中保存的值:{'name': 'TOM'}
print(Foo.__dict__) 输出类中所有内容:{'__module__': '__main__', '__init__': <function Foo.__init__ at 0x10ff261e0>, 'haha': <function Foo.haha at 0x10ff26268>, '__dict__': <attribute '__dict__' of 'Foo' objects>, '__weakref__': <attribute '__weakref__' of 'Foo' objects>, '__doc__': None}

浙公网安备 33010602011771号