1 import time 2 3 def timethis(func): 4 """ 5 测试函数运行花费时间的装饰器 6 """ 7 def wrapper(*args, **kwargs): 8 start = time.time() 9 result = func(*args, **kwargs) 10 end = time.time() 11 print("函数 %s 运行时间: %s" % func.__name__, end - start) 12 return result 13 return wrapper
时间: 2024-10-24 13:14:26