Python time 模塊time 函數的時間單位

Python 中time 模塊下的time 常用於計算函數運行的時間

import time 


starttime = time.time()
xxx
endtime = time.time()
print('xxx {:.5f} s'.format(endtime-starttime))

這裏的時間單位是秒(s), 可以參見官方文檔對此的描述(https://docs.python.org/3/library/time.html):

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章