Python 2 encode and decode

Source: Internet
Author: User

Https://docs.python.org/2/howto/unicode.html

A Unicode string is a sequence of code points, which was numbers from 0 to 0X10FFFF. This sequence needs to is represented as a set of bytes (meaning, values from 0–255) in memory. The rules for translating a Unicode string into a sequence of bytes is called an encoding.

A Unicode string is a sequence of encoded points, which is a numeric value from 0 to 0X10FFFF. This sequence needs to be represented in memory as a set of bytes (meaning values from 0 to 255). Translating a Unicode string into a sequence of bytes is called encoding.

UTF-8 is probably the most commonly supported encoding. UTF stands for "Unicode Transformation Format", and the ' 8 ' means that 8-bit numbers is used in the encoding

Utf-8 is the most commonly supported encoding. UTF means "Unified encoding conversion format", 8 means 8-bit encoded uniform encoding conversion format

Python's 8-bit strings has a .decode([encoding], [errors]) method that interprets the string using the given encoding

The Python 8-bit string has a decoding ([encoded],[Error]) method that interprets the string using the given encoding

The unicode() constructor has the signature unicode(string[, encoding, errors]) . All of its arguments should is 8-bit strings. The first argument is converted to Unicode using the specified encoding; If you leave off encoding the argument, the ASCII encoding are used for the conversion, so characters greater than 127 would be Treated as Errors

The Unicode () constructor has a flag function Unicode (string[, encoding, errors]). All parameters should be 8-bit strings. Converts the first argument to Unicode using the specified encoding, and if the encoding parameter is removed, the conversion is made using ASCII encoding, so characters greater than 127 are treated as errors.

Python 2 encode and decode

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.