python add datetime to filename

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

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'