Outcast
Outcast

Reputation: 5117

Replace accented letters with the respective non-accented ones at Python 3

I am not sure that this popular answer works in Python 3 since there is no unicode in Python 3.

Therefore, how can replace accented letters with the respective non-accented ones at Python 3?

For example,

sentence = 'intérêt'

to

new_sentence = 'interet'

Upvotes: 0

Views: 157

Answers (1)

chepner
chepner

Reputation: 531095

The linked answer references the third-party module unidecode, not Python 2's unicode type.

$ python3
Python 3.7.1 (default, Nov 19 2018, 13:04:22)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import unidecode
>>> unidecode.unidecode('intérêt')
'interet'

Upvotes: 1

Related Questions