import time
# 时间装饰器函数_统计时间差
def statistical_time(origin):#sum_num #statistical_time(sum_num) 3.
def inner(*args, **kwargs): #
start = time.time()
res = origin(*args, **kwargs) #res = sum_num()
end = time.time()
t = end - start
print(t)
return inner
@statistical_time # sum_num = statistical_time(sum_num) # inner 2.
def sum_num(i):
total = 1#
for _ in range(0,i):
total *= i
print(total)
time.sleep(2)
print(total)
sum_num(3) # 1.
#