码迷,mamicode.com
首页 > 编程语言 > 详细

Python5 - 字符编码

时间:2018-02-24 22:02:14      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:python   python3   python2   类型   body   就是   nic   code   div   

1.在python2默认编码是ASCII, python3里默认是unicode

2.unicode 分为 utf-32(占4个字节),utf-16(占两个字节),utf-8(占1-4个字节), so utf-16就是现在最常用的unicode版本, 不过在文件里存的还是utf-8,因为utf8省空间

3.在py3中encode,在转码的同时还会把string 变成bytes类型,decode在解码的同时还会把bytes变回string

Python5 - 字符编码

标签:python   python3   python2   类型   body   就是   nic   code   div   

原文地址:https://www.cnblogs.com/tanrong/p/8467620.html

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