原文:解决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