~~~
def decorator(func):
def wrapper(*args, **kw):
print(time.time())
func(*args, **kw)
return wrapper
# 原来只有打印 this is 现在还可以打印时间;
@decorator
def f1(func_name):
print('this is a function'+func_name)
@decorator
def f2(func_name1, func_name2):
print('this is a function' + func_name1)
print('this is a function' + func_name2)
@decorator
def f3(func_name1, func_name2, **kw):
print('this is a function' + func_name1)
print('this is a function' + func_name2)
print(kw)
f1('test abc')
f2('test abc21', 'test22')
f3('test func1', 'test func1', a=1, b=2, c='123')
~~~