1 In [11]: a = "a我爱我家!" 2 3 In [14]: a.encode("mbcs") 4 Out[14]: b'a\xce\xd2\xb0\xae\xce\xd2\xbc\xd2!' 5 6 In [16]: a.encode("mbcs").hex() 7 Out[16]: '61ced2b0aeced2bcd221' 8 9 In [17]: bytes.fromhex(_) 10 Out[17]: b'a\xce\xd2\xb0\xae\xce\xd2\xbc\xd2!' 11 12 In [21]: bytes.fromhex('61ced2b0aeced2bcd221').decode("mbcs") 13 Out[21]: 'a我爱我家!'
python str bytes bytearray 编码 解码
猜你喜欢
转载自www.cnblogs.com/hjbf/p/11967538.html
今日推荐
周排行