作业

7.利用装饰器为函数加上统计执行时间的功能。

  提示 time模块中的time()函数可以获取当前时间

import time

def decorator(f):
    def wrapper():
        a=time.time()
        print(a)            
        f()
        b=time.time()
        print(b)
        print(b-a)
    return wrapper()
@decorator
def now():
    print("2018-12-12")

 

posted @ 2018-12-13 09:27  火在风上飞  阅读(99)  评论(0编辑  收藏  举报