import time
def timestamp2datems(timestamp):
local_time = time.localtime(timestamp)
data_head = time.strftime("%Y-%m-%d_%H_%M_%S", local_time)
data_secs = (timestamp - int(timestamp)) * 1000
dt_ms = "%s_%03d" % (data_head, data_secs)
return dt_ms
if __name__ == '__main__':
ts = time.time()
print(timestamp2datems(ts))