简体   繁体   中英

saving the file in current date and time format

I'm logging sensor readings with timestamps.

I want to save the file in current date and time name format, like 2019-08-20-15-20.

Any idea how to make it?.

write_fmtt = " ".join("%4.8f" for _ in timestamped_camera_readings)
timestamped_camera_readings = np.append(float(timestamp),[arr1 , arr2 , arr3 , arr4])
write_fmtt += " %.0f"

with open("sensor reading.txt", "ab") as ff:
     np.savetxt(ff, np.expand_dims(timestamped_camera_readings, axis=0),fmt='%f')

you can do something like this:

with open("sensor reading {}.txt".format(datetime.now().strftime('%d-%m-%Y-%H-%M')), "ab") as ff:
    np.savetxt(ff, np.expand_dims(timestamped_camera_readings, axis=0),fmt='%f')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM