这篇文章说的比较清晰,链接:
http://www.imooc.com/wiki/flasklesson/flaskdecorator.html
文中举例:
import time
def decorate(input_sort):
def output_sort():
start_time = time.time()
input_sort()
end_time = time.time()
print('{}'.format(end_time - start_time))
return output_sort
@decorate
def quick_sort():
time.sleep(1)
quick_sort()