#!/usr/bin/python from time import ctime,sleep def tsfunc(func): def wrappedFunc(): print '[%s] %s() called' % (ctime().func.__name__) return func() return wrappedFunc @tsfunc def foo(): pass foo() sleep(4) for i in range(2): sleep(1) foo()
时间函数装饰器
原创
©著作权归作者所有:来自51CTO博客作者羡慕不来的原创作品,如需转载,请与作者联系,否则将追究法律责任
下一篇:Java类和对象
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
常用的10个Python装饰器
python中常用的10个装饰器
python 装饰器 py装饰器 -
Python 装饰器 函数
Python装饰器学习(九步入门):http://
示例代码 Python 带参数 -
用类作为装饰器装饰函数!
用类作为装饰器装饰函数!
类作 装饰器 装饰函数 -
利用装饰器计算函数运行的时间
计算函数运行的时间
python 运行时间 返回函数 分享