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?
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)Did you write the first line wrong?
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
Also check the encoding settings of the editor you are using. If you use vim, the vimrc file should have this content
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.