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