码迷,mamicode.com
首页 > 其他好文 > 详细

装饰器前奏(2017年8月20日 21:10:27)

时间:2017-08-20 22:36:59      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:bsp   知识   嵌套   变量   author   span   run   top   div   

实现装饰器知识储备

1、函数即“变量”

2、高阶函数

3、嵌套函数

 

# author :Yeison.Z

import time
def timmer(func):
    def warpper(*args,**kwargs):
        start_time=time.time()
        func()
        stop_time=time.time()
        print(‘the func run time is %s‘ %(stop_time-start_time))
    return warpper

@timmer
def test1():
    time.sleep(3)
    print(‘in the test1‘)

test1()

 

装饰器前奏(2017年8月20日 21:10:27)

标签:bsp   知识   嵌套   变量   author   span   run   top   div   

原文地址:http://www.cnblogs.com/yeison/p/7401444.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!