def get_time_stamp(ct):
local_time = time.localtime(ct)
data_head = time.strftime("%Y-%m-%d %H:%M:%S", local_time)
data_secs = (ct - int(ct)) *
time_stamp = "%s:%03d" % (data_head, data_secs)
return time_stamp
print(get_time_stamp(1546244983.3656037))
输出
-- :::
或者
import datetime print(datetime.datetime.now())
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S:%f'))
print(datetime.datetime.now().strftime('%Y%m%d%H%M%S%f'))