Member-only story
HOWTO: Remove diacritics (accents) from a text in Python
The most straightforward method for removing diacritics from a text in Python
In many cases, it is necessary to generate diacritics-free (accent-free) text before performing a variety of operations: filename generation, database saving, keyword generation, etc., and it can be somewhat challenging to generate this type of text because some methods result in the loss of one or more characters rather than their replacement.
For this reason, I will provide you, dear reader, with a Python function that works with any language and smoothly removes accents. It only requires installing the “unicodedata” library:
pip install unicodedata2
And the function is as follows:
Thus, dear reader, the process is not as complicated as it may appear, and by utilizing this function, you will enjoy a life free of any sort of diacritics.
Enjoyed this article? If you’re looking to dive deeper or have any questions, feel free to reach out to me on Twitter and LinkedIn. I’m always open…