python 装饰器 被装饰的函数存在参数的情况

‘’‘装饰器:被装饰的函数存在参数的情况’’’
‘’‘在inner函数内部需要传参,以便运行被装饰的函数’’’
def warp(func):
def inner(total):
print(‘验证’)
func(total)
return inner

@warp
def cost(total):
print(‘总付款金额:%s’%total)
print(‘总付款金额:’,total)

if name == ‘main’:
cost(10)
python 装饰器 被装饰的函数存在参数的情况
运行结果:
验证
总付款金额:10
总付款金额: 10