This article mainly introduces python Chinese encoding, which is a common problem in Python Programming. This article provides a detailed summary of this problem in the form of examples, if you need it, you can refer to the question of Chinese encoding, which has always been a headache in Python Programming. This article summarizes and summarizes this in detail. The details are as follows:
When the string is '\ u4e2d \ u56fd'
>>> S = ['\ u4e2d \ u56fd', '\ u6e05 \ u534e \ u5927 \ u5b66'] >>> str = s [0]. decode ('unicode _ escape ')#. encode ("EUC_KR") >>> print str China
When the string is: 'East Asian Study Group No. 1'
>>> Print unichr (19996) East
Ord () supports unicode and can display unicode numbers of specific characters, such:
>>>print ord('A')65
Unicode strings are generated as long as they are connected to Unicode. For example:
>>> 'help''help'>>> 'help,' + u'python' u'help,python'
For ASCII (7-bit)-compatible strings, you can convert Unicode strings into ASCII strings with the built-in str () function. For example:
>>> str(u'hello world')'hello world'
Understanding of several concepts:
The ASCII code corresponds to the corresponding characters using data words, as shown in:
Chinese is the Chinese character corresponding to the location code. For example, the "good" ASCII code is 22909
Unicode encoding is divided into one field for each country. It has UTF-8, UTF-16, UTF-32 and other forms
The Chinese value range is 4E00-9FBF. gbk, gb2312,
UTF-8 is a unicode-based international application.
Gb2312 and gb2312 are both early Chinese character codes used for encoding and decoding.
I hope this article will help you with Python programming.