def out01(f):
def inner01(*args, **kwargs):
print('out01-------')
print(f.__name__)
print(args)
print(kwargs)
print()
return f(*args, **kwargs)
return inner01
def out02(f):
def inner02(*args, **kwargs):
print('out02-------')
print(f.__name__)
print(args)
print(kwargs)
print()
return f(*args, **kwargs)
return inner02
@out01
@out02
def func(a, b):
return a + b
func(1, 2)
输出
out01-------
inner02
(1, 2)
{}
out02-------
func
(1, 2)
{}
函数 out01
装饰 out02
返回的函数 inner02
,inner02
继承的传入的参数来自于 func
传入的参数。