1 输出类的__dict__
class Test(object):
def __init__(self,name):
self.__name = name
print(Test.__dict__)
{'__module__': '__main__', '__init__': <function Test.__init__ at 0x0000027DFE27D9D0>, '__dict__': <attribute '__dict__' of 'Test' objects>, '__weakref__': <attribute '__weakref__' of 'Test' objects>, '__doc__': None}
所以,__init__,__dict__这些都是一个变量
2.对象的__dict__
class Test(object):
def __init__(self,name):
self.__name = name
a = Test('zs')
print(a.__dict__)
{'_Test__name': 'zs'}