原文:解決UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range

字符串在Python內部的表示是unicode編碼,因此,在做編碼轉換時,通常需要以unicode作為中間編碼,即先將其他編碼的字符串解碼 decode 成unicode,再從unicode編碼 encode 成另一種編碼。Decode的作用是將其他編碼的字符串轉換成unicode編碼,如str .decode gb ,表示將gb 編碼的字符串str 轉換成unicode編碼。 Encode的作用 ...

2019-03-11 11:18 1 9937 推薦指數:

查看詳情

 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM