strip unicode characters from strings python

Solutions on MaxInterview for strip unicode characters from strings python by the best coders in the world

showing results for - "strip unicode characters from strings python"
Agustín
05 Sep 2020
1
2def strip_non_ascii(string):
3    ''' Returns the string without non ASCII characters'''
4    stripped = (c for c in string if 0 < ord(c) < 127)
5    return ''.join(stripped)
6
7
8test = u'éáé123456tgreáé@€'
9print test
10print strip_non_ascii(test)