python打印ms

ct打印的是時間戳,時間戳的小數點後前三位爲ms  eg:1555644362.055328   ms = 055spa

import time

ct = time.time()
local_time = time.localtime(ct)
data_head = time.strftime("%Y-%m-%d %H:%M:%S", local_time)
data_secs = (ct - int(ct))  * 1000
time_stamp = "%s.%03d" % (data_head, data_secs)
print(ct)
print(local_time)
print(data_head)
print(time_stamp)
相關文章
相關標籤/搜索