Reputation: 115
This code works :
f = open('Report\\StatusReport.csv', 'w', newline='')
I need to add timestamp to the filename, something similar to :
time_stamp = time.strftime("%d-%m-%y_%H:%M:%S")
f = open(f'Report\\StatusReport_{time_stamp}.csv', 'w', newline='')
which gives the error :
OSError: [Errno 22] Invalid argument:
Upvotes: 0
Views: 432
Reputation: 4279
:
colons are not legal characters in windows file names
you should change this line
time_stamp = time.strftime("%d-%m-%y_%H:%M:%S")
to something line
time_stamp = time.strftime("%d-%m-%y_%H_%M_%S")
Upvotes: 3