python笔记之编码转换

1.decode和encode

 s.decode('utf-8').encode('utf-8')

decode():是解码

encode()是编码

isinstance(s,unicode):判断s是否是unicode编码,如果是就返回true,否则返回false

2.规则:

 python笔记之编码转换_第1张图片

3.python  内存字符串唯一  unicode

python笔记之编码转换_第2张图片

4.python打开图片:


5.python2与python3字符类型,编码转换区别:

python笔记之编码转换_第3张图片

文件存取编码转换图

python笔记之编码转换_第4张图片

常用编码介绍一览表

编码 制定时间 作用 所占字节数
ASCII 1967年 表示英语及西欧语言 8bit/1bytes
GB2312 1980年 国家简体中文字符集,兼容ASCII 2bytes
Unicode 1991年 国际标准组织统一标准字符集 2bytes
GBK 1995年 GB2312的扩展字符集,支持繁体字,兼容GB2312 2bytes
UTF-8 1992年 不定长编码 1-3bytes

你可能感兴趣的:(python学习笔记,python笔记之编码转换)