07 装饰器建议写法 关于前后
装饰器建议写法:
def x1(func):
def inner(*args,**kwargs):
data = func(*args,**kwargs)
return data
return inner
1.4 关于前后
def x1(func):
def inner(*args,**kwargs):
print('调用原函数之前')
data = func(*args,**kwargs) # 执行原函数并获取返回值
print('调用员函数之后')
return data
return inner
@x1
def index():
print(123)
index()