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
- Python裝飾器Python
- 裝飾器 pythonPython
- Python 裝飾器裝飾類中的方法Python
- Python裝飾器模式Python模式
- python的裝飾器Python
- 1.5.3 Python裝飾器Python
- Python 裝飾器(一)Python
- Python 裝飾器原理Python
- 草根學Python(十六) 裝飾器(逐步演化成裝飾器)Python
- python 之裝飾器(decorator)Python
- Python深入05 裝飾器Python
- Python裝飾器詳解Python
- Python中的裝飾器Python
- 【Python】淺談裝飾器Python
- 初識Python裝飾器Python
- Python 裝飾器的理解Python
- python裝飾器介紹Python
- 淺談Python裝飾器Python
- .NET程式碼樹執行時間計時器
- python程式計算執行時間差Python
- Python3 裝飾器解析Python
- Python 語法之裝飾器Python
- Python裝飾器高階用法Python
- python裝飾器入門探究Python
- python 裝飾器 part2Python
- python裝飾器有哪些作用Python
- python裝飾器是什麼Python
- Python 裝飾器簡單示例Python
- 粗淺聊聊Python裝飾器Python
- python中裝飾器的原理Python
- Python閉包與裝飾器Python
- Python之函式裝飾器Python函式
- Python深入分享之裝飾器Python
- Python裝飾器的前世今生Python
- python 裝飾器小白學習Python