How to remove accent in Python? [duplicate]

1

In R would make this in this way iconv('Arapeí', to="ASCII//TRANSLIT") , so is there any simple way to do this in Python?

    
asked by anonymous 11.12.2018 / 19:09

2 answers

3

Use unidecode:

$ pip install unidecode

from unidecode import unidecode
print(unidecode('Arrepieí'))
Arrepiei

str = 'café'
print(unidecode(str))
cafe
    
11.12.2018 / 19:22
2

Use unidecode:

from unicodedata import normalize

source = 'Arapeí'
target = normalize('NFKD', source).encode('ASCII','ignore').decode('ASCII')
print(target)
    
11.12.2018 / 19:25