def decoratorA(func):
print(33)
def wrapperA():
print("Entering A")
print(func())
print("Exiting A")
print(44)
return wrapperA
def decoratorB(func):
print(11)
def wrapperB():
print("Entering B")
func()
print("Exiting B")
print(22)
return wrapperB
@decoratorB
@decoratorA
def my_function():
print("Inside my_function")
return 34
# 调用被装饰器包装的函数
my_function()
结果展示:
标签:function,顺序,return,示例,python,func,print,my,def From: https://www.cnblogs.com/zhansheng/p/18324196