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'))

Leave a Comment