Skip to content

Instantly share code, notes, and snippets.

@mohitkh7
Created July 16, 2018 05:44
Show Gist options
  • Save mohitkh7/9be513bdaf94bf54e348532a978ff169 to your computer and use it in GitHub Desktop.
Save mohitkh7/9be513bdaf94bf54e348532a978ff169 to your computer and use it in GitHub Desktop.
Python codefile to save file with name as timestamp of accuracy upto millisecond
# Python code to save a file with timestamp of accuracy upto millisecond
from datetime import datetime as dt
current_time = dt.now() # current system time e.g. 2018-07-16 16:34:43.050328
current_time_as_str = str(current_time)
filename = current_time_as_str + ".txt"
file = open(filename, "w+") # Create a empty text file with timestamp name
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment