摘要: 一、装饰器是什么 python的装饰器本质上是一个Python函数,它可以让其他函数在不需要做任何代码变动的前提下增加额外功能,装饰器的返回值也是一个函数对象。简单的说装饰器就是一个用来返回函数的函数。 它经常用于有切面需求的场景,比如:插入日志、性能测试、事务处理、缓存、权限校验等场景。装饰器是解 阅读全文
posted @ 2020-06-19 10:21 John-Python 阅读(441) 评论(0) 推荐(0) 编辑
摘要: import time def count_time(func): def wrapper(*args, **kwargs): start_time = time.time() count = func(*args, **kwargs) print('程序共计%s秒' % (time.time() 阅读全文
posted @ 2020-06-19 10:12 John-Python 阅读(131) 评论(0) 推荐(0) 编辑