unicode coding
# -*- coding = UTF-8 -*-
does not work ?
Big thanks
# -*- coding = UTF-8 -*-
does not work ?
Big thanks
Since you cited PEP-263, read carefully the regular expression it gives for what the coding line should match:
^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)
specifically, the string coding
should be immediately followed by a :
or =
, no whitespace. The encoding name UTF-8
is fine since encoding names are not case-sensitive.
The most common way to write this is:
# -*- coding: utf-8 -*-
Note: Since this is just a standard Python feature it is not specific to Sage, so you could also likely find answers to your problem on StackOverflow or any other source for Python help.
In what way does it "not work" for you? I just tested in this on Sage 8.9 with Python 2.7 on Windows and it works as expected. On Python 3 it's not necessary because all files are treated as UTF-8 encoded by default unless specified otherwise.
See PEP263. Note that UTF-8
does not appear in the standard encodings list. So maybe try # -- coding = utf_8 --
(lowercase, underscore).
The imminent Python 3-based Sage 9 should solve the problem..
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2019-12-19 10:35:23 +0100
Seen: 379 times
Last updated: Dec 23 '19
Why Sage can not plot Chinese label
UnicodeDecodeError in Notebook Server if Worksheet is set to 'python' instead of 'sage'
UnicodeDecodeError in matplotlib if 'python' set instead of 'sage' in Notebook [closed]
from __future__ import unicode_literals and variable names
try