python add datetime to filename

Solutions on MaxInterview for python add datetime to filename by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "python add datetime to filename"
Guadalupe
05 Sep 2020
1from datetime import datetime
2
3date = datetime.now().strftime("%Y_%m_%d-%I:%M:%S_%p")
4print(f"filename_{date}")
5
6'filename_2020_08_12-03:29:22_AM'