解码带有 python 和葡萄牙语字符的字符串

Decoding a string with python with portuguese characters

所以我有这段从互联网上提取的文本,有些词没有使用正确的字符,比如这个 "experiências"。 python 中是否有任何函数或其他东西,我可以在其中处理这样的字符串并转换为葡萄牙语版本。喜欢体验。

谢谢!

你"pulled"不是Unicode字符串而是西欧编码的字符串,可能是CP1252。您必须将其编码回字节对象,然后正确解码。

"experiências".encode("cp1252").decode()
# 'experiências'