元类作用是什么:定制类的创建行为
动态创建类:
def init(self,name):
self.name = name
return
def hello(self):
print("hello:self name :",self.name)
return
Foo = type('Foo',(object,),{"__init__":init, "hello":hello, "cls_var":10})
foo = Foo("zhangsan")
foo.hello()
print(foo.cls_var)
=======================输出===================
hello:self name : zhangsan
10