解决python3 unicode decode问题的通用方法

1810阅读 0评论2022-05-01 zenith518
分类:大数据

有时候,遇到 unicode decode 问题解决也非常麻烦。
现在总结一下,我常用的两个个方法,其中自认为效果非常好,而且比较通用。

#如果有特别字符无法用unicode表达,直接删除了之, 例如 \u30fb
outputstr = outputstr.replace("\u30fb","")

#一般比较通用的处理方式
import unicodedata
outputstr = unicodedata.normalize("NFKD", outputstr)

zenith 2022-05-01 闭关修炼中
上一篇:Ubuntu Samba/CIFS Server简单部署和配置
下一篇:如何在PowerShell中执行带引号的指令