1.统计运行时间
import time def cal_time(func): def wrapper(*args, **kwargs): t1 = time.time() x = func(*args, **kwargs) t2 = time.time() print("%s running time %s secs."%(func.__name__, t2-t1)) return x return wrapper
import time def cal_time(func): def wrapper(*args, **kwargs): t1 = time.time() x = func(*args, **kwargs) t2 = time.time() print("%s running time %s secs."%(func.__name__, t2-t1)) return x return wrapper