一、代码
class_name='car'dict_name={}bases=(object,)class_body='''def __init__(self,name): self.name=namedef driver(self): print('%s汽车开走了',self.name)'''#将类体内容放入名称空间exec(class_body,{},dict_name)print(dict_name)car=type(class_name,bases,dict_name)print(car)