2013-09-30 48 views
0

我想在Python3中使用unidecode庫來刪除俄語單詞(西裏爾字母)中的重音符號。 unidecode lib適用於其他示例,但不適用於俄語單詞。任何幫助將不勝感激。Python3 unidecode無法轉換西里爾文字母

而不是在 「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 
>>> 

回答

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變量。

+0

謝謝,它確實是LANG和LC_ *設置。我正在使用en_US,並將其設置爲en_US.UTF-8,並且工作正常。 – menphix