remove unicode characters from string python code example
Example 1: remove unicode from string python
.encode("ascii", "ignore")
Example 2: python remove all unicode from string
return ''.join([i if ord(i) < 128 else ' ' for i in text])
Example 3: strip unicode characters from strings python
def strip_non_ascii(string):
''' Returns the string without non ASCII characters'''
stripped = (c for c in string if 0 < ord(c) < 127)
return ''.join(stripped)
test = u'éáé123456tgreáé@€'
print test
print strip_non_ascii(test)