Skip to content

Instantly share code, notes, and snippets.

@victorono
Last active August 1, 2020 21:58
Show Gist options
  • Save victorono/7633010 to your computer and use it in GitHub Desktop.
Save victorono/7633010 to your computer and use it in GitHub Desktop.
Eliminar tildes string python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unicodedata
def elimina_tildes(cadena):
s = ''.join((c for c in unicodedata.normalize('NFD',unicode(cadena)) if unicodedata.category(c) != 'Mn'))
return s.decode()
string_acentos = 'café'.decode('utf-8')
sin_tildes = elimina_tildes(string_acentos)
print sin_tildes
@TheKingOfShadows98
Copy link

Gracias man, es muy útil.

@nsuat-dev
Copy link

Único inconveniente es que elimina la 'ñ'. Pero sigue siendo muy útil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment