Non-ascii character bug in Python and Pycharm code area suddenly can't edit the problem

Source: Internet
Author: User
Tags control characters shebang

1:pycharm code area Suddenly can't edit the problem

Workaround:

(1) If Pycharm is using a free trial version, this can happen because the trial is over! Re-download continue to use or purchase, download free version can solve this problem

(2) to exclude (1) The problem is that the software itself when you open the error occurred! Turn it off and then turn it back on to solve the problem

2:python non-ascii character bug when using Chinese annotation in the process of writing code again

The code hints in

  Control Panel are: Syntaxerror:non-ascii character in file testpy3/t.py on line 5but Span class= "Hljs-title" >no encoding declared; see http://python. Org/dev/peps/pep-0263/for details

< Span class= "Hljs-command" > This means that there is a problem with Chinese garbled

Workaround:

python defaults to ASCII encoding when writing code. The code has the following characteristics:

1, the concept: is based on the Latin alphabet a set of computer coding system. It is primarily used to display modern English, while its extended version Eascii can partially support other Western European languages and is equivalent to ISO/IEC 646.
2. Features: ASCII code uses the specified 7-bit or 8-bit binary number combination to represent 128 or 256 possible characters. The standard ASCII code is also called the base ASCII code, using a 7-bit binary number to represent all uppercase and lowercase letters, numbers 0 through 9, punctuation, and special control characters used in American English

So to define a Chinese source code code, there must be a magical comment, placed at the beginning of the file. As shown below:

#!/usr/bin/python

#-*-Coding: <encoding name>-*-
The encoding of the Chinese language is the following code is OK!

#!/usr/bin/python

#-*-Coding:utf8-*-

Non-ascii character bug in Python and Pycharm code area suddenly can't edit the problem

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.