我有一个足球运动员的名字列表,但无法正确打印带有重音字符的名字。我查看了许多 StackOverflow 帖子,但似乎找不到有效的解决方案。
现在,当我想要 Alexis Sánchez
时,我只能输出 Alexis S\u00e1nchez
。
最佳答案
对于 Python 3.x:
>>> print(bytes('Alexis S\\u00e1nchez', 'ascii').decode('unicode-escape'))
Alexis Sánchez
和 Python 2.x:
>>> print("Alexis S\\u00e1nchez".decode("unicode-escape"))
Alexis Sánchez
关于python - 如何将unicode转换为Python字符串中的重音字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58121898/