类的定义

class Foo:
    def __init__(self, x):
        self.x = x


print(Foo)


def __init__(self,x):
    self.x = x


FFo = type('FFo',(object,), {'__init__': __init__})
print(FFo)
print(FFo.__dict__)

f = FFo(1)
print(f.x)
原文地址:https://www.cnblogs.com/majianyu/p/10269426.html