话不多说,代码伺候
先看如下代码,对装饰器的执行过程简单了解
def deco(func): #3
def wrap(*args, **kwargs):#5
print 'blala' #6
func(*args, **kwargs) #7
return wrap #4
@deco # 2
def need_deco(*args, **kwargs): #8
print args, kwargs #9
need_deco() # 1
# 调用函数的时候顺序#1-9
接下来仔细研读菜鸟教程:
https://www.runoob.com/w3cnote/python-func-decorators.html
还可以参看CSDN: