Python crawled to the page source code has a similar \u51a0\u7434, how to convert to Chinese?
Reply content:
Found a library called AST, there is a function, called Literal_eval.
Xie invited, more familiar with the standard library (7.8. Codecs
) Bar:
>>> s = r'\u51a0\u7434'>>> print s\u51a0\u7434>>> s.decode('unicode_escape')u'\u51a0\u7434'>>> print s.decode('unicode_escape')冠琴
2014-11-25
After looking at the wheel brother's answer, think of Python 3.x provides the Ord and CHR two built-in functions. Implements the conversion between Unicode code point and characters.
ongoing-study/ucps.py at Master Myd7349/ongoing-study GitHub
There is no Python 2 handy. Orz
2015-06-03
The content of the previous answer is misleading! I am sorry.
How to get Unicode code in Chinese in Python3? -Myd7349 's answer
----
' u\u51a0\u7434 ' is not U ' \u51a0\u7434 ', the Lord himself does not understand the meaning of the things he searched, @ Liu Xiang also do not know what the main question (found after the hint has already known the main question asked what). This 51a0 and 7434 represent 16 binary 4 bytes, which is Unicode encoding, Python certainly has to provide numbers to character or byte array to string function, you have to process them into numbers, and then go.
Javascript:
this is actually This is actually
UnicodeCode. Unicode uses a 16-bit integer to represent any character that exists in the world, that is, any character that can be displayed corresponds to an integer in Unicode.
This notation is an escape notation for Unicode characters, followed by \u with the word corresponding to the Unicode integer.
hexadecimalnotation to represent a Unicode character.
More than just Python,
a large number of programming languages use two-byte Unicode as the basic character type。 such as Java and JavaScript.
There are a number of tools that can help you convert text to Unicode. For example: 16 characters コードin javaユニコード