码迷,mamicode.com
首页 > 其他好文 > 详细

字符编码

时间:2019-03-09 22:00:24      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:str   python3   bsp   ascii   1.0   中文   unicode   编码   字符编码   

二进制   0101010

  ASCII     只能存英文和拉丁字符,一个字符占一个字符。8位

    gb2312  只能6700多个中文   1980年

      gbk1.0  存了2万多个字符   1995年

        gb18030   27000中文    2000年

    unicode utf-32  一个字符占4个字节

    unicode utf-16  一个字符占2个字节或2个以上,65535

    unicode utf-8   一个英文用ASCII码存储,一个中文占3个字节

编码 encode      

解码 decode

 

in python2 默认编码ASCII

  # -*- coding:uft-8 -*-  

  # -*- coding:gbk -*-  

  用法

  str.decode(‘utf-8‘)

in python3默认unicode

 

字符编码

标签:str   python3   bsp   ascii   1.0   中文   unicode   编码   字符编码   

原文地址:https://www.cnblogs.com/ljw-blogs/p/10503067.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!