Discuss / Python / 交作业

交作业

Topic source

🍉

#1 Created at ... [Delete] [Delete and Lock User]
def metric(fn): 
    def abc(*a,**ab):
        ti=time.perf_counter() #开始
        ab=fn(*a,**ab) # 被装饰函数执行
        print(f'{fn.__name__}执行时间:{time.perf_counter()-ti:.8f}s') #当前时间-开始时间=函数执行时间
        return ab
    return abc

  • 1

Reply