Region: IOError: [Errno 22] invalid mode ('w') or filename

Use forward slashes:

'path/regionlog.txt'

Or raw strings:

r'path\regionlog.txt'

Or at least escape your backslashes:

'path\\regionlog.txt'

\r is a carriage return.


Another option: use os.path.join and you won't have to worry about slashes at all:

output = os.path.abspath(os.path.join('path', 'regionlog.txt'))

In C standard language, \t, \n, \r are escape characters. \t is a transverse to the next TAB position. \n is a newline and \r is a carriage return. You should use \\r or /r, and you will solve the problem!


Additionaly, Python also gives this message when trying to open a file > 50 MB from a SharePoint shared drive.

https://support.microsoft.com/en-us/help/2668751/you-cannot-download-more-than-50-mb-or-upload-large-files-when-the-upl

Tags:

Python

Ioerror