Gary Sieling

UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xe1′ in position 8: ordinal not in range(128)

If you do the following:

[str(x) for x in data]

You’ll sometimes get this error:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 8: ordinal not in range(128)

This indicates that you have non-ascii characters in the data, and should use a wider type. You can fix it by doing the following (alternately, you can do something like base64 encoding, although I’m not sure why you’d want to do that):

[unicode(x) for x in data]
Exit mobile version