#传参
def parameter_test(aa):
#装饰器
def decorator(func):
#装饰函数
def wrapper(*args,**kwargs):
print('decorator parameters:%s' %aa)
print("wrapper start")
res = func(*args,**kwargs)
res += " : wrapper add"
print("wrapper end")
return res
return wrapper
return decorator
#带语法糖(装饰器)的函数
@parameter_test(aa='123')
def foo(name,age):
print('this is foo')
print(name,age)
return 'foo end'
res = foo('lds',12)
print(res)