就连 object 也是由type创建的 哈哈,就连type自己也是type创建的
In [1]: type(type) Out[1]: type In [2]: type(object) Out[2]: type In [3]: type(int) Out[3]: type In [4]: type(str) Out[4]: type In [5]: type(bool) Out[5]: type In [6]: type(list) Out[6]: type 有点神奇样 str:用来创建字符串对象的类int:用来创建整数对象的类type:用来创建类对象的类等等…示例
# 继承type class Base(type): def __new__(cls,*args,**kwargs): print('in Base') return super().__new__(cls,*args,**kwargs) class Person(metaclass=Base): def __init__(self,name): self.name = name p = Person('tom') # 控制台 in Base