装饰器计算函数耗时:
def clock(func): "用于计算函数耗时的装饰器" def funCountTime(*args, **kwargs): startTime = time.time() result = func(*args, **kwargs) endTime = time.time() timeCost = endTime - startTime print(f'func<{func.__name__}> timeCost: {timeCost} s') return result return funCountTime