I tried this code in Python 2:
def NewFunction():
return '£'
But I get an error message that says:
SyntaxError: Non-ASCII character '\xa3' in file '...' but no encoding declared;
see http://www.python.org/peps/pep-0263.html for details
Similarly, in Python 3, if I write the same code and save it with Latin-1 encoding, I get:
SyntaxError: Non-UTF-8 code starting with '\xa3' in file ... on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
How can I use a pound sign in string literals in my code?
See also: Correct way to define Python source code encoding for details about whether an encoding declaration is needed and how it should be written. Please use that question to close duplicates asking about how to write the declaration, and this one for questions asking about resolving the error.