2018-10-16
阅读量:
1139
python2 的encode和decode errors
1.问题描述

这个例子中,是上一节的encode错误,我们在其后面的参数加上了’replace’这个选项,然后就没有报错,取而代之的是问号。

这里例子中,参数改成了’ignore’,这个的意思是忽略编码错误,所以结果是个空字符
这些处理方法同样适用于decode 的错误解决。

当然这并不是最好的解决方法,这些只是防止一些不能编码的问题出现造成程序的exception,所以在编写程序的时候,特别是使用python2处理中文的时候,还是得小心翼翼的写,说多了都是泪。






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
1条评论