The source code of the web page captured by python is similar to u51a0u7434. How can I convert it to Chinese?

Source: Internet
Author: User
The source code of the web page captured by python is similar to u51a0u7434. How can I convert it to Chinese? The source code of the webpage captured by python is similar to \ u51a0 \ u7434. How can I convert it to Chinese?
Reply content: Find a library named ast, which contains a function called literal_eval.
Thank you for choosing to familiarize yourself with the standard library (7.8. codecs :

>>> S = R' \ u51a0 \ u7434 '>>> print s \ u51a0 \ u7434 >>> s. decode ('unicode _ escape ') U' \ u51a0 \ u7434' >>> print s. decode ('unicode _ escape ') Guan Qin

After reading the answer from wheel brother, I thought that Python 3. x provides two built-in functions: ord and chr. Unicode code point and character conversion.
Ongoing-Study/ucps. py at master · myd7349/Ongoing-Study · GitHub
Python 2 is unavailable at hand. Orz.
2015-06-03
The previous answers are misleading! Sorry.
In Python3, how do I obtain the Chinese corresponding to the Unicode code? -Myd7349
----

'U \ u51a0 \ u7434 'is not U' \ u51a0 \ u7434'. The subject does not understand what it means, @ Liu Xiang: he does not know what the subject is asking (he knows what the subject is asking after receiving the prompt ). This 51a0 and 7434 represent the 4 bytes in hexadecimal format. This is unicode encoding. python must provide a function to convert numbers to character or byte arrays to strings. You must first process them into numbers, and then turn.

Javascript:
This is actually This is actually Unicode. Unicode uses a 16-bit integer to represent any character in the world, that is, any character that can be displayed corresponds to an integer in Unicode.
This method is the escape method of Unicode characters. It is added after \ u to correspond to the Unicode integer. HexadecimalA Unicode character.

Not only Python, In a large number of programming languages, two bytes of Unicode are used as the basic character type.. For example, Java and Javascript.
There are many tools that can help you convert text to Unicode. For example, when the 16-level text is written in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.