python3编码方式

ascii:
A:00000001 8位 1个字节

unicode
A:00000000 00000000 00000000 00000001 32位 4个字节

utf-8
A:0000 0010 8位 1个字节
中文:00000000 00000000 00000001 24位 3个字节

gbk
A:00000001 8位 1个字节
中文:00000000 00000001 16位 2个字节

1、各个编码之间的二进制是不能互相转化识别,会乱码
2、unicode 文件的储存和传输不能是Unicode,只能是utf-8 or gbk or ascii...

python3:
str:在内存当中使用unicode编码的
bytes类型(utf-8 or gb2312 or gbk or ascii...编码)
对于英文:
str:表现形式:s = 'ss'
编码方式:00000001 unicode
bytes:表现形式:s = b'ss'
编码方式:00000001 utf-8 or gbk or ascii
对于中文:
str:表现形式:s = 'ss'
编码方式:00000001 unicode
bytes:表现形式:s = b'x\e66\e66\e66\e66\e66\e66\e66'
编码方式:00000001 utf-8 or gbk or ascii...

 



posted on 2018-12-20 16:56  耳矝  阅读(173)  评论(0编辑  收藏  举报

导航