Can python input Chinese?

爱喝马黛茶的安东尼
Release: 2019-06-19 09:26:25
Original
3813 people have browsed it

Solution to two applications of Chinese input:

Can python input Chinese?

Add language coding statement "-*- coding: uft-8 -*-"# in the script

##Application 1:

Chinese appears in print

Method 1:

Use unicode(' ' , encoding = 'utf-8' ) or unicode(" ", encoding = "utf-8" )

Related recommendations: "

python video tutorial"

Can python input Chinese?

Method 2:

Use u' ' or u" "

Can python input Chinese?

Apply 2: Chinese characters appear in

function input, such as raw_input()

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

Method 1:

unicode() transcoding, declare it as gbk, and print the text uniformly Declaration

Can python input Chinese?

Method 2:

unicode() transcoding, the declaration is gbk, and the text printing indicates utf-8, that is Yes, don’t emphasize the gbk encoding

Can python input Chinese?

The above is the detailed content of Can python input Chinese?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template