# 开放封闭原则:对扩展是开放,对修改是封闭
# 装饰器:装饰她人的,器指的是任意可调用对象,现在的场景装饰器>>:函数,被装饰的对象也是函数
# 原则:不修改被装饰对象的的源代码
# 不修改被装饰对象的调用方式
# 装饰器的目的,在遵循原则的前提下,为被装饰对象添加上新功能
# import time
#
# def index():
# time.sleep(3)
# print('Welcome to China')
#
# start=time.time() # 时间戳,显示的是以秒为单位的时间
# index()
# stop=time.time()
# print('run time is %s'%(stop-start))
'''
Welcome to China
run time is 3.000962257385254
'''
# import time
#
# def index():
# time.sleep(3)
# print('Welcome to China')
# def timmer(func):
# start = time.time() # 时间戳,显示的是以秒为单位的时间
# func()
# stop = time.time()
# print('run time is %s' % (stop - start))
#
# timmer(index)
'''
Welcome to China
run time is 3.0009765625
'''
# import time
#
# def index():
# time.sleep(3)
# print('Welcome to China')
# def outter(func):
# def timmer():
# start = time.time()
# func()
# stop = time.time()
# print('run time is %s' % (stop - start))
# return timmer
#
# f=outter(index)
# print(f)
# f()
# '''
# <function outter.<locals>.timmer at 0x000002314AB24DC8>
# Welcome to China
# run time is 3.0000648498535156
# '''