Python Coding issues

Source: Internet
Author: User
Chinese iso8859-1 encoding to UTF8 encoding

Str.encode ("GBK"). Decode ('gbk '). Encode (' Utf-8 ' )

Principle:

UTF8 encoded text can be expressed in iso8859-1 encoding, but not in the reverse. Iso8859-1 is a single-byte encoding, and UTF8 is a fixed-length encoding, converted from UTF8 to iso8859-1 equivalent to high-precision conversion to low precision, resulting in loss of precision, so irreversible. The root cause is because UTF8 Chinese, there is no matching position in iso8859-1.

While GBK is an indefinite length code, the character encoding rules for English numerals are the same as those of iso8859-1, so GBK is compatible with ISO8859-1 encoding, which can be converted to each other.

Python Coding issues

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.