python 获取秒级时间间隔

 

import datetime,time
start_tm=datetime.datetime.now()
time.sleep(2)
end_tm=datetime.datetime.now()
print((end_tm-start_tm).seconds)

输出

 2

 

posted @ 2019-04-28 21:41  anobscureretreat  阅读(3301)  评论(0编辑  收藏  举报