代码语言:javascript复制
#/usr/bin/env python3
import time
def outer(key):
def timer(func):
def wrapper(*args,**kwargs):
print(key)
s=time.time()
res=func(*args,**kwargs)
e=time.time()
print(e-s)
return res
return wrapper
return timer
@outer('dec info')
def do(a):
time.sleep(1)
print(a)
return a 1