使用Python删除变音标记 [英] Removing diacritical marks using Python

查看:53
本文介绍了使用Python删除变音标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个带有变音符的字符的文本文件,例如èá等。我想用 e a o

I have a couple of text files with characters which has diacritical marks, for example è, á, ô and so on. I'd like to replace these characters with e, a, o, etc

如何在Python中实现呢?感谢帮助!

How can I achieve this in Python? Grateful for help!

推荐答案

尝试unidecode(您可能需要安装它)。

Try unidecode (you may need to install it).

>>> from unidecode import unidecode
>>> s = u"é"
>>> unidecode(s)
'e'

这篇关于使用Python删除变音标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆