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

Posted yeison

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了装饰器前奏(2017年8月20日 21:10:27)相关的知识,希望对你有一定的参考价值。

实现装饰器知识储备

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)的主要内容,如果未能解决你的问题,请参考以下文章