首页 > 编程语言 > 详细

python time装饰器log 类似Java 中注解

时间:2019-11-17 17:05:22      阅读:107      评论:0      收藏:0      [点我收藏+]

 

‘‘‘
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))

 

python time装饰器log 类似Java 中注解

原文:https://www.cnblogs.com/lshan/p/11876872.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!