装饰器

最后更新于:2022-04-02 02:17:41

``` def log(f): def fn(*args, **kw): print('call ' + f.__name__ + '()...') # 真正需要添加的功能 return f(*args, **kw) return fn @log def factorial(n): from functools import reduce return n**2 print(factorial(10)) # call factorial()... # 3628800 ```
';