Created
April 20, 2018 12:37
-
-
Save Fhernd/c765ea5b36a520eda0dc7078db0799af to your computer and use it in GitHub Desktop.
Limpiar y asegurar texto. Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unicodedata | |
import sys | |
python = 'pýthöñ\fis\tawesome\r\n' | |
print(python) | |
mapa_caracteres = { | |
ord('\t'): ' ', | |
ord('\f'): ' ', | |
ord('\r'): None | |
} | |
python = python.translate(mapa_caracteres) | |
print(python) | |
caracteres_combinados = dict.fromkeys(c for c in range(sys.maxunicode) | |
if unicodedata.combining(chr(c))) | |
python = unicodedata.normalize('NFD', python) | |
print(python) | |
print(python.translate(caracteres_combinados)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment