About Python error: syntaxerror:non-ascii character ' \xe5 ' in file solution The first thought is to set the Pydev encoding in Eclipse, try the following operation
We all know that the Win7 default encoding is GBK, and Ubuntu under Default is Utf-8, sometimes our code needs to be edited under two platforms, so it is necessary to set up the eclipse code, which is not only used for Pydev,android ADT is similar. Just set the main 3 places to open Eclipse's windows-preferences:
- The content types option selects the corresponding file type, such as Python Files,java source files, and then fills in UTF-8 in the default encoding below, remembering to click after setting Update button, otherwise ...
- editor-text editor-spelling tab in the encoding, the default is Utf-8 then do not change, if not, then select the following in the other Utf-8,ok
- The Workspace tab in the text file encoding also selects Utf-8 yo, pro
- If it is Android, the above three-step design is OK, but Pydev also need a step, that is, at the beginning of each py file with a line of encoding:utf-8, manual plus sure not, then we set in the template. pydev-editor-templates tab, set several options for the new module in the context, with the #encoding in front : Utf-8 .
Remember in Win7 and Ubuntu to set this time, when the two sides open source files will not appear garbled.
But this still can not solve the error, in fact, it is simple to add a statement
#coding =utf-8
This statement should be placed at the beginning of the position.
Python syntaxerror non ASCII character xe5 in file