Python3 unidecode无法转换西里尔字母

时间:2013-09-30 15:30:52

标签: unicode python-3.x cyrillic

我正在尝试使用Python3中的unidecode库删除俄语单词中的重音(用西里尔字母表)。 unidecode lib适用于其他示例,但不适用于俄语单词。任何帮助将不胜感激。

而不是删除“e”字母上的重音,俄语单词变为“ND3 / 4D3 / 4D + -NDuID1 / 2D,N”,这不是我们想要的......

Python 3.3.0 (default, Oct 24 2012, 14:30:03)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> # -*- coding: utf-8 -*-
...
>>> from unidecode import unidecode
>>> print(unidecode(u"Cœur"))
CAur
>>> print(unidecode(u"сообще́ния"))
ND3/4D3/4D+-NDuID1/2D,N
>>>

1 个答案:

答案 0 :(得分:0)

我试过Mac OSX。

$ echo $LANG
en_US.utf-8
$ python3
Python 3.3.2 (default, Aug 22 2013, 12:33:42)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from unidecode import unidecode
>>> print(unidecode(u"Cœur"))
Coeur
>>> print(unidecode(u"сообще́ния"))
soobshcheniia

您可以尝试设置LANG变量。

相关问题