__class__和type的关系
__class__和type
其实一个对象的__class__就是这个对象的元类,type打印的其实就是对象的__class__
class zx():
pass
z = zx()
print(z.__class__ == zx)
print(type(z) == zx)
True
True
证明
class zx1():
pass
z1=zx1()
class zx():
pass
z = zx()
print(z.__class__ == zx)
z.__class__= z1.__class__
print(type(z) == zx)
True
False