字符串有多种编码汉字怎么处理

stevenxxxx stevenxxxx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
曣 yàn,
部首: 日 部首笔画: 4 总笔画: 20
曣
yàn
(1)古同“晏”,晴朗 许慎注淮南子云:“晏,无云也。”即晴朗没有云彩的天空
(2)暖

>>> s0 = "曣"
>>> chardet.detect(s0)
{'confidence': 0.5, 'encoding': 'windows-1252'}
>>> s="我是曣"
>>> chardet.detect(s)
{'confidence': 0.99, 'encoding': 'GB2312'}

>>> s.decode("gb2312")
Traceback (most recent call last):
File "<pyshell#38>", line 1, in <module>
s.decode("gb2312")
UnicodeDecodeError: 'gb2312' codec can't decode bytes in position 4-5: illegal multibyte sequence


有复杂汉字 请教这种情况怎么处理?
...全文
评论 6
收藏 已收藏
分享
返回顶部
stevenxxxx
脚本语言 37,738 成员 34,208 内容