写代码原则: 开放封闭原则 装饰器的固定模式 def func(): time.sleep(1) print('你好') def timmer(f): def inner(): strattime = time.time() f() endtime = time.time() print(endtime-starttime) return inner func = timmer(func) func()