# __author__ = ‘ZSnail‘
import time
def test1() :
time.sleep(3)
print(‘in the test1‘)
def test2() :
time.sleep(3)
print(‘in the test2‘)
# 如果不修改源代码情况下添加功能
# 高阶函数
# def deco(function) :
# start = time.time()
# function()
#
#
stop = time.time()
# print(‘the time is %s‘ %s(start - stop))
# 使用:
# deco(?function?) 修改了调用方式
# 如果不修改调用方式
# test1 = deco(test1)
#装饰器
#wrapper 包装
def demo(func) :
def wapper(*arr, **obj):
start = time.time() # 功能
func(*arr, **obj) # 传进去参数
stop = time.time() # 功能
print(‘the time is %s‘ %(stop - start))
return wapper
@demo
def test3() :
time.sleep(3)
print(‘lallalalalalla‘)
test3()
# part57