To solve SyntaxError: Non-ASCII character ‘\xa3’ in file when function returns ‘£’ error follow below methods.
SyntaxError: Non-ASCII character '\xa3' in file 'blah' but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
How to solve SyntaxError: Non-ASCII character ‘\xa3’ in file when function returns ‘£’ ?
Refer the given methods to solve the issue.
I’d recommend reading the PEP that the error provides. Your code is attempting to use ASCII encoding, yet the pound symbol is not an ASCII character. Consider using UTF-8 encoding. At begin, add
# -- coding: utf-8 -- to the top of your
.py file. To get more complex, you can define encodings in your code on a string-by-string basis. If you want to use the pound sign literal in your code, you’ll need an encoding that supports it throughout the file.
Method 2 :
Adding the below two lines also works in some cases.
#!/usr/bin/env python # -*- coding: utf-8 -*-
Hope the above solution works.
Also read :