用装饰器实现打印时间

import time
def b(func):
def call_time(*args,**kwargs):
start_time=time.time()
ret=func(*args,**kwargs)
end_time=time.time()
c=end_time-start_time
print(c)
return call_time
@b
def test(*args,**kwargs):
for i in range(100):
print(i)
test()
posted @ 2018-05-22 21:05  孟庆健  阅读(379)  评论(0编辑  收藏  举报