只要实现此
obj(func)()
模式,这个obj就叫一个装饰器------------------------------>参考https://cloud.tencent.com/developer/article/1114856
https://www.cnblogs.com/lianyingteng/p/7743876.html
函数装饰器
例子
---
def decorator(func):
def inner(*args, **kwargs):
print('before...........')
res = func(*args, **kwargs)
print('after............')
return res
return inner
@decorator
def run():
print('run...............')
return 0
if __name__ == "__main__":
run()
run.__name__
# 此时decorator叫做装饰器
------------------------------------------
before