How to avoid encoding parameter when opening file in Python3
Question: When I am working on a .txt file on a Windows device I must save as either:
ANSI, Unicode, Unicode big endian, or UTF-8. When I run Python3 on an OSX
device and try to import and read the .txt file, I have to do something along
the lines of:

    
    
    with open('ships.txt', 'r', encoding='utf-8') as f:
        for line in f.readlines():
            print(line)
    

Is there a particular format I should use to encode the .txt file on the
Windows device to avoid adding the encoding parameter when opening the file in
Python?


Answer: Call `locale.getpreferredencoding(False)` on your OSX device. That's the
default encoding used for reading a file on that device. Save in that encoding
on Windows and you won't need to specify the encoding on your OSX device.

But as the [Zen of Python](https://www.python.org/dev/peps/pep-0020/) says,
"Explicit is better than implicit." Since you know the encoding, why not
specify it?

