Run Python file for the first time with eclipse / pydev: “UTF-8 ‘codec can’t decode byte 0xc4 in position

Today, after successfully installing pydev with eclipse, try to run it. Since the creation date of the file contains Chinese characters by default, the Unicode error as shown in the figure appears after running  

Online solutions to find two, and then I have derived a third (focus). The method is as follows

Method 1: File & gt& gt; Properties>& gt; Text file encoding>& gt; O ther:utf-8

After completing the above steps, there will be garbled code, delete and re-enter Chinese characters can be normal operation!

 
Method 2: edit & gt& gt; Set Encoding  & gt;& gt; O ther:utf-8 (the same as the method one by one, there will be garbled codes. Just delete them and input them again.)

 
Method 3: right click on the python project/Package & gt& gt; Properties and method 1 are similar operations

The first two methods are both temporary but not permanent, that is, they can only solve the Unicode error of the current file, and a new Python file will still have a Unicode error; After using method 3, as long as the file is created under the project, its encoding is UTF-8, and there will be no Unicode   It solves the problem from the root.

Method 3: discovery process

In method 1, in properties & gt& gt; In run/debug setting, I found that the current code setting object is only the current file, so I thought of giving it to the whole python   Project to set the encoding, so right-click the mouse on the project, found the projperties option, according to the operation of method 1 to try, successfully solved the Unicode problem   So there is method 3


Read More: