定向 一个 nbsp python all elf python 类 pre init
- class Test():
- def __init__(self, func):
- print('装饰器1')
- self.__func = func
- def __call__(self):
- print('装饰器2')
- self.__func()
- @Test #等价于test = Test(test),将test重定向到一个新的函数
- def test():
- print('函数')
- test()
python 类装饰器
- 装饰器1
- 装饰器2
- 函数
来源: http://www.bubuko.com/infodetail-2447097.html