#z装饰器
import time
def deco(func):
def wrapper():
startT = time.time()
func()
endT = time.time()
msecs = (endT - startT)*1000
print("it's %f ms" % msecs)
return wrapper
@deco
def myfunc():
print('myfunc start......')
time.sleep(1.7)
print('myfunc end......')
print("myfunc is",myfunc.__name__)
#@deco 代替这段代码myfunc = deco(myfunc)
print('#'*50)
print('myfunc is',myfunc.__name__)
myfunc()