Home > Article > Backend Development > Can python input Chinese?
Solution to two applications of Chinese input:
Add language coding statement "-*- coding: uft-8 -*-"# in the script
##Application 1:
Chinese appears in printMethod 1:
Use unicode(' ' , encoding = 'utf-8' ) or unicode(" ", encoding = "utf-8" ) Related recommendations: "python video tutorial"
Method 2:
Use u' ' or u" "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 DeclarationMethod 2:
unicode() transcoding, the declaration is gbk, and the text printing indicates utf-8, that is Yes, don’t emphasize the gbk encodingThe above is the detailed content of Can python input Chinese?. For more information, please follow other related articles on the PHP Chinese website!