3 ms·
Python supports writing Unicode literals in any encoding, but you have to declare the encoding being used. This is done by including a special comment as either
by js2 15y ago
Python supports writing Unicode literals in any encoding, but you have to declare the encoding being used. This is done by including a special comment as either the first or second line of the source file:
# -*- coding: latin-1 -*-
The syntax is inspired by Emacs’s notation for specifying variables local to a file. Emacs supports many different variables, but Python only supports ‘coding’. The dash-splat-dash symbols indicate to Emacs that the comment is special; they have no significance to Python but are a convention. Python looks for coding: name or coding=name in the comment.
http://docs.python.org/howto/unicode.html http://docs.python.org/howto/unicode.html