python source fileencoding
Some of the python source file starts with -*- coding: utf-8 -*-. This particular linetells python interpreter all the content (byte string) is utf-8 encoded. Lets see how it affects the code.
uni1.py:
# -*- coding: utf-8 -*- print("welcome") print("animé") output:
➜ code$ python2 uni1.py welcome animé Third line had a accented character and it wasn’t explictly stated as unicode. print function passed successfully.Since first line instructed interpreter all the sequences from here on will follow utf-8, so it worked.
[Read More]