语法糖 python_Python___语法糖
生活随笔
收集整理的這篇文章主要介紹了
语法糖 python_Python___语法糖
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Python___語(yǔ)法糖
import time
def timer(func):
def deco():
start_time=time.time()
func()
stop_time=time.time()
print("the func run time is %s" %(stop_time-start_time))
return deco
def test1():
time.sleep(3)
print('in the test1 !!!!!')
print(timer(test1))
test1=timer(test1)
test1()
執(zhí)行結(jié)果:
.deco at 0x005F5270>
in the test1 !!!!!
the func run time is 3.0
............................................................................
print(timer(test1))
的執(zhí)行結(jié)果為:
.deco at 0x005F5270>
test1=timer(test1)
test1()
的執(zhí)行結(jié)果為:
in the test1 !!!!!
the func run time is 3.0
總結(jié)
以上是生活随笔為你收集整理的语法糖 python_Python___语法糖的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vue2.0项目部署到服务器_vue项目
- 下一篇: 索罗斯在1997赚了多少钱 狙击泰铢白嫖