python 获取两个时间戳相差多少毫秒

code

import time
import datetime

t1=time.time()
time.sleep(0.02)
t2=time.time()

print("相差",(datetime.datetime.fromtimestamp(t2)-datetime.datetime.fromtimestamp(t1)).microseconds/1000.0,"ms")

原文地址:https://www.cnblogs.com/sea-stream/p/14049844.html