[SOLVED] OSError: [Errno 22] Invalid argument - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: [SOLVED] OSError: [Errno 22] Invalid argument (/thread-10721.html) Pages:
1
2
|
RE: OSError: [Errno 22] Invalid argument - wavic - Jun-03-2018 Well, there is something in the filename that is not excepted in Windows. I don't remember what the allowed characters for filenames are. Perhaps the colons? You have to change the datetime format. For example. I don't use often the datetime module os I had to look ar the documentation str(datetime.datetime.now().strftime('%Y-%m-%d %Hh%Mm%Ss')) RE: OSError: [Errno 22] Invalid argument - Panda - Jun-03-2018 (Jun-03-2018, 02:39 PM)buran Wrote: the colon is not allowed in file name. Use something likeThank you. This fixed it RE: OSError: [Errno 22] Invalid argument - buran - Jun-03-2018 I would construct the filename on separate line log_file = 'Path to the log file/Logs/log{}.log'.format(datetime.datetime.now().strftime('%Y%m%d%H%M%S_%f')) hdlr = logging.FileHandler(log_file) RE: OSError: [Errno 22] Invalid argument - volcano63 - Jun-04-2018 You cannot have colon sign as part of file name |