"""多个装饰器装饰一个函数,执行效果类似于俄罗斯套娃(3210123),难点在于各种传值"""
def wapper(func):#func=inner2
def inner1(*args,**kwargs):
print('子丑寅卯')
ret=func(*args,**kwargs)
print('辰巳午未')
return ret
return inner1
def wapper2(func):#func=inner1
def inner2(*args,**kwargs):
print('申酉戌亥')
ret=func(*args,**kwargs)
print('完成')
return ret
return inner2
@wapper #Nauth=wapper(inner2)=func=inner1
@wapper2 #Nauth=wapper2(Nauth)=func=inner2
def Nauth():
print('嵌套')
return 'MOBA'
print(Nauth())
转载于:https://www.cnblogs.com/sihong/p/11056948.html