恶心的字符编码

字符编码
内存默认用unicode-快
磁盘用的utf-8-小

#存储过程中
内存unicode --decode--> utf-8磁盘
utf-8磁盘 --encode--> 内存unicode

 

#执行过程中
内存unicode --encode--> utf-8(bytes)
utf-8(bytes) --decode--> 内存unicode


python3 所有字符串都是unicode
所以字符串只有 encode方法
*.py 文件头上面 写的是代码保存在硬盘上的,以及读取的字符集

python2中 字符串类型有俩种
str
unicode

str --decode--> utf-8
没有encode
unicode 和python3一样

 

posted @ 2017-05-16 16:35  昂达达  阅读(258)  评论(0编辑  收藏  举报