Current location - Quotes Website - Famous sayings - How does python input Chinese?
How does python input Chinese?
Two applications to solve Chinese input;

Add the language encoding statement "-*- coding: uft-8 -*-" to the script.

Python learning network, a large number of free Python video tutorials, welcome to learn online!

Application 1: Chinese appears in printed matter.

Method 1: Use unicode (',encoding = 'utf-8') or unicode (",encoding = "utf-8").

Related recommendation: Python introductory course

Method 2: Use u'' or u "".

Application 2: Chinese appears in the function input, such as raw_input ().

Use unicode (','utf-8'). Encoding ("gbk") or unicode ("utf-8"). encode ("gbk ")?

Method 1: unicode () transcoding, the statement is gbk, and a unified statement is printed on the text.

Method 2: unicode () transcoding, stating that it is gbk, only indicating that the text is printed in utf-8, without emphasizing gbk encoding.