简体   繁体   English

Python中的UTF-8解码错误

[英]UTF-8 decoding error in Python

I'm trying to do this in Python: 'Fi\\xc3\\xb1a'.decode('utf-8') 我正在尝试在Python中执行此操作: 'Fi\\xc3\\xb1a'.decode('utf-8')

I expect the result to be Fiña . 我希望结果是Fiña But the result is actually: u'Fi\\xf1a' 但结果实际上是: u'Fi\\xf1a'

No idea what is going on, some help on this would be much appreciated. 不知道发生了什么,对此将提供一些帮助。

Thanks! 谢谢!

You're getting the correct result, the Unicode codepoint for ñ is U+00f1. 您得到的是正确的结果, ñ的Unicode代码点是U + 00f1。 It's just that Python won't display the Unicode character directly. 只是Python不会直接显示Unicode字符。 Try it in a print statement and see what you get. print语句中尝试一下,看看会得到什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM