class Test(object): def __init__(self,func): self.func=func def __call__(self, *args, **kwargs): print('这是一个类装饰器') return self.func() @Test def get_str(): return 'hahaha' print(get_str())
简单应用,了解即可