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")
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")