# 第一个装饰器函数
def decorator_a(func):
print("Get in decorator_a")
def inner_a(*args, **kwargs):
print("Get in inner_a")
return func(*args, **kwargs)
return inner_a
# 第二个装饰器函数
def decorator_b(func):
print("Get in decorator_b")
def inner_b(*args, **kwargs):
print("Get in inner_b")
return func(*args, **kwargs)
return inner_b
@decorator_b
@decorator_a
def f(x): # 被装饰函数
print("Get in f")
return x * 10
f(5)
#结果:
Get in decorator_a
Get in decorator_b
Get in inner_b
Get in inner_a
Get in f
多重装饰器先执行后被调用的,先出来Get in decorator_a我理解,然后到return inner_a,调用这个inner_a函数不是应该先出Get in inner_a这句话吗,为什么结果是b的