1

我正在尝试自动化一个应用程序,它就像谷歌引擎一样。当用户输入“société”(重音字符)时,它会给出包含“société”(重音符号)或“societe”(英语)的详细信息。

所以我的工作是验证详细信息是否包含给定的关键字。我在比较重音字符时没有问题。例如:“société”=“société”。但案例“société”==“societe”失败了。Python代码如下:

 >>> "société".find("societe")
 -1 #Fail
 >>> "société".find("société")
 0  #Success
 >>> 

那么如何在重音字符中匹配等效的英文单词。

任何帮助将不胜感激。谢谢

4

1 回答 1

1

您可以使用unidecode

>>> from unidecode import unidecode
>>> unidecode(u"société")
societe
于 2015-07-20T11:20:54.903 回答