【发布时间】:2019-12-09 21:43:43
【问题描述】:
我正在尝试在我的 HTML 解析之后清除一些奇怪的 unicode 字符,但仍然没有转换这些 unicode。
原文:
raw = 'If further information is needed, don´t hesitate to contact us. Kind regards, José Ramirez.'
编解码后:
text = str(raw.encode().decode('unicode_escape'))
当前输出:
'If further information is needed, donÃ\x82´t hesitate to contact us. Kind regards, JosÃ\x83© Ramirez'
期望的输出:
'If further information is needed, don´t hesitate to contact us. Kind regards, José Ramirez'
【问题讨论】:
标签: python-3.x decode python-unicode unicode-string