装饰器本身接受被装饰的对象,装饰器返回的可调用对象接受被装饰对象的所有参数
import time
def runtime(funtion):
def get_now_time(name,**kwargs):
print(time.time())
funtion(name,**kwargs)
return get_now_time
@runtime
def run(name):
print('my name is {}'.format(name))
run("Lory", a="hello")
运行结果
1584700003.9577506
my name is Lory
网友评论