字符编码

一、字符编码
'''
了解  
GB2312 ===> GBK(***) ===>GB1803
​
unicode表 and utf-8
    内存就是unicode存储数据
    硬盘、cup采用utf-8存取数据
    unicode与utf-8采用的是一张unicode编码表,utf-8是unicode编码表体现方式,变长存储数据。
​
#--encoding:utf-8 ----(***)
'''
二、字符与字节

字符占多少字节,字符串转化 ***

'''
unicode字符串,默认字符串:
    s1 = u'abc你好
不好'
字节字符串:
    s2 = b'abcxb7xb7'
原义字符串:不对字符串内部做任何操作(eg:
的转化)
    s3 = r'abc你好
不好'
​
'''

编码解码

'''
原义字符串:
    r'.abc
abc' =>'abc
abc'
将u字符串编码成b字符串
    编码:u''.encode('utf-8')  | bytes(u''.encode='utf-8')
将b字符串编码成u字符串
    编码:b''.ducode('utf-8’)  | str(b''.ducode='utf-8')
​
'''
 
原文地址:https://www.cnblogs.com/tyler-bog/p/10600288.html