Advertisement
Fhernd

limpiar-asegurar-texto.py

Apr 20th, 2018
3,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. import unicodedata
  2. import sys
  3.  
  4. python = 'pýtĥöñ\fis\tawesome\r\n'
  5.  
  6. print(python)
  7.  
  8. mapa_caracteres = {
  9.     ord('\t'): ' ',
  10.     ord('\f'): ' ',
  11.     ord('\r'): None
  12. }
  13.  
  14. python = python.translate(mapa_caracteres)
  15.  
  16. print(python)
  17.  
  18. caracteres_combinados = dict.fromkeys(c for c in range(sys.maxunicode)
  19.             if unicodedata.combining(chr(c)))
  20.  
  21. python = unicodedata.normalize('NFD', python)
  22.  
  23. print(python)
  24.  
  25. print(python.translate(caracteres_combinados))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement