类的定义

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)

 

posted @ 2019-01-14 22:25  我爱敲代码  阅读(105)  评论(0编辑  收藏  举报