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?
某草草2017-06-12 09:21:44
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)
天蓬老师2017-06-12 09:21:44
#!/usr/bin/env python
# -*- coding: utf-8 -*-
Did you write the first line wrong?
学习ing2017-06-12 09:21:44
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.