Python character encoding

Source: Internet
Author: User

Python character encoding


    1. The earliest character encoding standard: ASCII

      1. 127 characters, no Chinese

      2. 1 English letters required 1 bytes

8 bits = 1 bytes

1024 bytes =1kb

1024kb=1mb

Later, in order to extend Chinese support, there appeared GB2312, GBK later appeared Unicode
    1. Unify all languages into one set of codes.

    2. Each character occupies 2 bytes


Final UTF-8 (compression and optimization of Unicode)
    1. 1 English 1 bytes

    2. 1 Chinese 3 bytes

Python3. X default Unicode encoding, Chinese python2 is supported by default. X default ASCII encoding, unable to support Chinese
    1. Support Chinese Way:

      #!/bin/bash/env python #解释器

      #_ *_ coding:utf-8 _*_ #加字符集


This article is from the "506554897" blog, please be sure to keep this source http://506554897.blog.51cto.com/2823970/1906358

Python character encoding

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.