1.timmer是装饰器函数 test是被装饰的函数
import time def test(): time.sleep(1) print("---------------") def timmer(f): def inner(): start = time.time() f() end = time.time() print(end - start) return inner test = timmer(test) test()
import time def test(): time.sleep(1) print("---------------") def timmer(f): def inner(): start = time.time() f() end = time.time() print(end - start) return inner test = timmer(test) test()