SyntaxError: Non-UTF-8 code starting with '\\x

2020-02-06 11:45发布

问题:

SyntaxError: Non-UTF-8 code starting with '\x90' in file
C:\Python36\python.exe on line 1, but no encoding declared

I don't understand why it shows me that when I want to open the interpreter. Can someone help me please?

回答1:

Ok, it's a wrong value for PYTHONSTARTUP which was asking me a problem. Thank you all !



回答2:

Python 3 assumes scripts are saved with UTF-8 encoding. The script being executed (from PYTHONSTARTUP?) is not UTF-8-encoded. If you know the encoding, you can add it to the top of the script with:

#coding:cp1252     (or whatever the encoding is).

Or just re-save the script in UTF-8.

See also PEP 0263.