def wrapper1(func): #传入参数inner2 def inner1(): print('之前1') func() print('之后1') return inner1 def wrapper2(func): #传入参数f def inner2(): print('之前2') func() print('之后2') return inner2 @wrapper1 #f=wrapper1(f) f=wrapper(inner2) @wrapper2 #语法糖离被装饰函数越近就越先执行 f = wrapper2(f) inner2 def f(): print('alex') f()