June 2017
Beginner
352 pages
8h 39m
English
Getting the encoding right is crucial for correctly interpreting the contents of a text file, so we want to labor the point a bit. Python can't reliably determine the encoding of a text file, so it doesn't try. Yet without knowing the encoding of a file, Python can't properly manipulate the data in the file. That's why it's critical that you tell Python which encoding to use.
If you don't specify an encoding Python will use the default from sys.getdefaultencoding(). In our case, the default encoding is 'utf-8':
>>> import sys>>> sys.getdefaultencoding()'utf-8'
Always remember, though, that there's no guarantee that the default encoding on your system is the same as the default encoding on another system with which ...
Read now
Unlock full access