How to define python source code encoding?
While using non-ASCII characters in your code, you might get this error: "SyntaxError: Non-ASCII character '\xc3' in file myprog.py on line 101, but no encoding declared;".
Solution is to define encoding at the beginning of your source code.
Syntax:
Example:
For details check http://www.python.org/dev/peps/pep-0263/.
Solution is to define encoding at the beginning of your source code.
Syntax:
# -*- coding: desired_encoding -*-
Example:
# -*- coding: iso-8859-1 -*-
For details check http://www.python.org/dev/peps/pep-0263/.
Comments