美文网首页
Python计算时间差

Python计算时间差

作者: Jiafu | 来源:发表于2018-11-14 17:39 被阅读0次
import datetime
import time

oldtime=datetime.datetime.now()
print oldtime;
time.sleep(1)
newtime=datetime.datetime.now()
print newtime;
print '相差:%s'%(newtime-oldtime)
print '相差:%s微秒'%(newtime-oldtime).microseconds
print '相差:%s秒'%(newtime-oldtime).seconds

相关文章

网友评论

      本文标题:Python计算时间差

      本文链接:https://www.haomeiwen.com/subject/lynjfqtx.html