装饰器
#Author:Kevin_hou import time def timer(func): #timer(test1) func= test1 def deco(*args, **kwargs): start_time= time.time() func(*args, **kwargs) stop_time= time.time() print("the func run time is %s" %(stop_time-start_time)) return deco @timer def test1(): time.sleep(3) print('in the test') @timer def test2(): time.sleep(3) print('in the test2') test1() test2()