Python Decoding Coding Essentials

Source: Internet
Author: User

    1. Understanding key points: a standard abstraction with a concrete implementation, two codes consistent

      1. Coding specification standards such as Unicode, encoding specific implementation: such as UTF8 (remember the key points, easy to understand)

      2. The correct output, the content of the display is encoded in accordance with the actual type of local coding system

        1. The character encoding that is declared within the program file or the IDE is sometimes different from the actual encoding

        2. Python uses MBCS for win local code ( Program Files strongly recommend Unicode implementation)

        3. Local coded character set may not include specific characters

      3. To correctly decode the decode string itself, encode the encoding to be consistent with the actual type of codec specified

    2. Key points of use: three u

      1. Generate Chinese file name in program:u' Chinese file name '

      2. File, IDE encoding is best unified using uTf8

      3. Database Chinese best unicode

    3. eg

>>>print ' Yan '. Decode (' UTF8 '). Encode (' GBK ') strict >>>print u ' Yan '. Encode (' GBK ')

Python Decoding Coding Essentials

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.