python怎麼把字符轉換為unicode編碼

來源:魅力女性吧 1.35W
python怎麼把字符轉換為unicode編碼

實現代碼如下:a = 'abce'# print type(a)b = de("ascii"

)# print type(b)c = de("ascii")de("utf-8"

)# print type(c)在python中進行編碼轉換都是通過unicode作為中間值實現的。所以要先decode成unicode字符,然後再使用encode轉換成utf-8編碼的str。可以把註釋取消了,看下轉換過程中的類型。

熱門標籤