python time装饰器log 类似Java 中注解
时间:2019-11-17 17:05:22
收藏:0
阅读:110
‘‘‘ Created on 2019年11月2日 @author: Administrator ‘‘‘ import time def timefun(func): def wrappedfunc(): print("start the method : %s"%(func.__name__)) start = time.time() rst = func() end = time.time() print("end the method : %s"%(func.__name__)) print("total cost time :", str((end-start))) return rst return wrappedfunc @timefun def foo(): time.sleep(1) print("I am foo") @timefun def getInfo(): return ‘----hahah---‘ f = foo() print(type(f))
原文:https://www.cnblogs.com/lshan/p/11876872.html
评论(0)