#装饰器的应用源于开放封闭原则
# import time
# def show_time(object):
# def inner():
# start=time.time()
# object()
# end=time.time()
# bet=end-start
# print(bet)
# return inner
#
# @show_time #rain=show_time(rain)
# def rain():
# time.sleep(2)
# print('rain')
#
# rain()
#
#装饰器参数 给装饰器加上一个参数使其满足一定条件时再执行
# import time
# def logger(flag=''):
# def log(object):
# def inner(*a):#与函数参数一致
# start=time.time()
# object(*a)
# print(time.time()-start)
# return inner
# if flag=='true':
# print('记录日志')
# return log
#
# @logger('ture')
# def add(*args): #功能函数加参数是三个位置,一功能函数,2装饰函数3三被装饰函数
# time.sleep(2)
# sum=0
# for i in args:
# sum+=i
# print(sum)
#
# add(1,2)
https://www.zhihu.com/question/26930016