python获取系统当前时间,获取到ms的

import time
import datetime

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

你可能感兴趣的:(python)