python打印ms

ct打印的是时间戳,时间戳的小数点后前三位为ms  eg:1555644362.055328   ms = 055

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)

 

posted @ 2019-04-19 11:31  小心走火  阅读(926)  评论(0编辑  收藏  举报