Here is what I try to do and I use windows and Python 3.3
LOG_FILENAME = 'log_trial_%s.txt' % datetime.datetime.now().strftime('%m%d-%H:%M:%S')
log_fd = open(LOG_FILENAME, 'w')
log_fd.write('===================\n')
The above codes are of course a part of a module and whe I ran the module, I got an error message as follows:
log_fd = open(LOG_FILENAME, 'w')
OSError: [Errno 22] Invalid argument: 'log_trial_1209-11:39:40.txt'
I have no idea what the long weird log finame means (‘log_trial_%s.txt’ …) and how to fix the error thing as well.
I will appreciate your time and help.
Windows file names can’t have colons in them.
Try this instead: