python计算时间的装饰器

import pandas as pd
 
def calcMethodsTimes(func):
    def inner(*args, **kwargs):
        start = pd.datetime.now()
        res = func(*args, **kwargs)
        end = pd.datetime.now()
        print("methods: %s ,运行共计耗时: %s s"%(func.__name__,  end - start))
        return res
    return inner
 
 
 
@calcMethodsTimes
def fun():
    return 


posted @ 2022-10-28 22:01  下个ID见  阅读(76)  评论(0)    收藏  举报