Python - 如何改变像 é 这样的字母

Python - How to change letters like é

python 中是否有函数可以将 é 转换为 e,或 í 转换为 i?

是的,您可以通过以下过程过滤和映射字符串的字符:

from unicodedata import normalize, category

''.join([c for c in normalize('NFD',original) if category(c) != 'Mn'])

在这里我从你的问题中过滤掉这些口音:

>>> original = 'Is there a function in python which converts letters like é to e, or í to i?'
>>> from unicodedata import normalize, category
>>> ''.join([c for c in normalize('NFD',original) if category(c) != 'Mn'])
'Is there a function in python which converts letters like e to e, or i to i?'