[英]Decode french in python
I need to parse french string ("Vidéo") from UTF-8 file. 我需要从UTF-8文件中解析法语字符串(“Vidéo”)。 But I get
'Vid\\xc3\\xa9o'
instead of desired sting. 但是我得到
'Vid\\xc3\\xa9o'
而不是想要的刺痛。
I tried decode('utf-8') but it will fail with following result: 我尝试了解码('utf-8'),但是它将失败,并显示以下结果:
'Vid\xe9o'
How to fix this encoding issue? 如何解决此编码问题?
'\\xe9'
is the correct representation of the unicode 'é'. '\\xe9'
是'\\xe9'
的正确表示。 \\x
is the string escape sequence for a hexadecimal character and 'e9' is the hexadecimal value of the character 'é'. \\x
是十六进制字符的字符串转义序列,而'e9'是字符'é'的十六进制值。 If you write the value of the string 'Vid\\xe9o'
to a file and open it with a program which supports displaying unicode characters, it should show up as 'Vidéo'. 如果将字符串
'Vid\\xe9o'
的值写入文件,并使用支持显示Unicode字符的程序将其打开,则该文件应显示为“Vidéo”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.