python裝飾器 執行時間
#/usr/bin/env python3
import time
def outer(key):
def timer(func):
def wrapper(*args,**kwargs):
print(key)
s=time.time()
res=func(*args,**kwargs)
e=time.time()
print(e-s)
return res
return wrapper
return timer
@outer('dec info')
def do(a):
time.sleep(1)
print(a)
return a+1
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4606/viewspace-2809954/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- python裝飾器2:類裝飾器Python
- Python 裝飾器Python
- Python裝飾器Python
- 1.5.3 Python裝飾器Python
- Python 裝飾器(一)Python
- python的裝飾器Python
- Python 裝飾器原理Python
- Python裝飾器模式Python模式
- Python深入05 裝飾器Python
- python 之裝飾器(decorator)Python
- Python中的裝飾器Python
- Python裝飾器詳解Python
- python程式計算執行時間差Python
- python裝飾器入門探究Python
- python 裝飾器 part2Python
- day11(python)裝飾器Python
- python中裝飾器的原理Python
- Python裝飾器高階用法Python
- python 裝飾器小白學習Python
- 【python】閉包與裝飾器Python
- Python裝飾器的前世今生Python
- python的裝飾器@的用法Python
- Python深入分享之裝飾器Python
- Python 語法之裝飾器Python
- Python3 裝飾器解析Python
- Python閉包與裝飾器Python
- Python之函式裝飾器Python函式
- Python 裝飾器簡單示例Python
- python裝飾器有哪些作用Python
- python裝飾器是什麼Python
- 粗淺聊聊Python裝飾器Python
- python之為函式執行設定超時時間(允許函式執行的最大時間)Python函式
- Python迭代器&生成器&裝飾器Python
- python幾種裝飾器的用法Python
- Python學習筆記 - 裝飾器Python筆記
- Python 裝飾器你也會用Python
- Python:從閉包到裝飾器Python
- python中的裝飾器介紹Python