__author__ = 'sam'
#无参数装饰器
def w1(func):
def inner():
print("xxxx")
func()
return inner
#确定参数装饰器
def func1(functionName):
def func_in(a, b):
print("func_ini")
functionName(a, b)
return func_in
#不确定参数装饰器
def func2(functionName):
def func_in(*args, **kwargs):
print("func_in")
functionName(*args, **kwargs)
return func_in
@w1
def s1():
print("--s1--")
@func1
def z1(a, b):
print("---test--- a = %d, b = %d" % (a, b))
@func2
def z2(a, b, c):
print("--test-- a=%d, b=%d, c=%d" % (a, b, c))
s1()
z1(1, 2)
z2(1, 2, 3)