Python Chinese garbled problem
仅有的幸福
仅有的幸福 2017-06-12 09:19:44
0
3
799

I have added this part of the code to the head of the file. Why is there still an ASCII encoding error?

#!/usr/bin/python
# -*- coding: utf-8 -*-

SyntaxError: Non-ASCII character 'xe6' in file .... but no encoding declared; see http://python.org/dev/peps/pe... for details

why?

仅有的幸福
仅有的幸福

reply all(3)
某草草

Look at the entire file source code, or you can try # coding: utf8 (Warm reminder, this coding statement must be on the first or second line to be valid)

Peter_Zhu
#!/usr/bin/env python
# -*- coding: utf-8 -*- 

Did you write the first line wrong?

学习ing

Check the encoding format of your file. It should not be Unicode-like UTF-8, etc. Try Notepad++, open the file and select the encoding to see if you want to convert it to UTF-8, etc.

In Linux environment, first check the encoding of the file

file -bi [filename]

Also check the encoding settings of the editor you are using. If you use vim, the vimrc file should have this content

set encoding=utf-8
set fileencoding=utf-8

Because the issue of encoding "environment" is related to your operating system and editing environment, you can remember to mention it when you ask questions.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template