装饰器
import time
def decorator(func):
# **kw:key word
# *args 可变参数
def wrapper(*args,**kw):
print(time.time())
func(*args,**kw)
return wrapper
@decorator
def f1(func_name):
print(“this is 装饰器” + func_name)
f1(’ funcname’)
@decorator
def f2(func_name2,func_type2):
print(‘def2’ + func_name2 + func_type2)
f2(’ f2 '," type " )
@decorator
def f3(func_name3,func_type3,**kw):
print(‘def3’ + func_name3 + func_type3)
print(kw)
f3(" name3 “,” type 3 ",a=1,b=2,c=“3”)
f2(“22”,“33”)
f1(“1”)