标签:nbsp 字符串 nic 关于 utf-8 编码方式 pre upper --
bytes s1 = ‘alex‘ b1 = b‘alex‘ print(b1,type(b1)) print(b1.upper()) s1 = b‘屌丝‘ b1 = s1.encode(‘utf-8‘) print(s1) s1 = ‘太白‘ unicode ---> gbk 字符串 ---> gbk编码方式的bytes b1 = s1.encode(‘gbk‘) # 编码 s2 = b1.decode(‘gbk‘) # 解码 print(s2) s2 = ‘太白‘ unicode ---> utf-8 字符串 ---> utf-8 编码方式的bytes b2 = s2.encode(‘utf-8‘) s3 = b2.decode(‘utf-8‘) print(s3) gbk ---> utf-8 b1 = b‘\xcc\xab\xb0\xd7‘ # gbk编码的bytes类型 s = b1.decode(‘gbk‘) b2 = s.encode(‘utf-8‘) # utf-8编码的bytes类型 print(b2) s1 = ‘いらないよ‘ b = s1.encode(‘shift_jis‘) # s2 = b.decode(‘shift_jis‘) # print(b) print(s2)
标签:nbsp 字符串 nic 关于 utf-8 编码方式 pre upper --
原文地址:https://www.cnblogs.com/jack20181017/p/10182700.html