代码如下:
import datetime
t1 = "14:27:07.857"
t1 = datetime.datetime.strptime(t1, '%H:%M:%S.%f')
t2 = "14:27:08.817"
t2 = datetime.datetime.strptime(t2, '%H:%M:%S.%f')
deltat_sec = (t2 - t1).seconds
deltat_ms = (t2 - t1).microseconds / 1000
print(deltat_sec) # t2和t1之间相差0秒
print(deltat_ms) # t2和t1之间相差960.0毫秒
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)