如何替换python中的重音字符?

问题描述:

我的输出看起来像àéêöhello!".我需要像这样更改我的输出 'aeeohello',只需将字符 à 替换为这样.

My output looks like 'àéêöhello!'. I need change my output like this 'aeeohello', Just replacing the character à as a like this.

嗨 Ganesh 请使用下面的代码.

Hi Ganesh Please Use the below code.

它对我有用!

import unicodedata

def strip_accents(text):

    try:
        text = unicode(text, 'utf-8')
    except NameError: # unicode is a default on python 3 
        pass

    text = unicodedata.normalize('NFD', text)\
           .encode('ascii', 'ignore')\
           .decode("utf-8")

    return str(text)

s = strip_accents('àéêöhello')

print s