[Python] eclipse + pydev syntaxerror: Non-ASCII character problem solution

Source: Internet
Author: User

 

Eclipse + pydev syntaxerror: Non-ASCII character problem solution

It's hard to get an eclipse + pydev High.

The tragedy is that when there is a Chinese string, the wildcard is prone to syntaxerror: Non-ASCII character.

Okay. Solve this annoying problem.

Add #-*-coding: UTF-8-*-or: # Coding = UTF-8 at the beginning of each code file

PS: If you want to be lazy and do not want to add the above line to every new file

You can choose Window> preferences> pydev> editor> templates.

Select <empty> on the right, click Edit, and then add the above line to add the new line.

(You can also create a new one, but you must select the one you created instead of the default empty when creating the module)

Compile again...

Finally there is no such error prompt...

But...

Chinese cannot be output normally.

Good

Let's change the eclipse

Window-> preferences-> General-> workspace, find "text file encoding", select other, select "UTF-8"

OK

Then compile...

Everything is normal

.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.