Why do I get a UnicodeEncodeError when printing a Response object?

Viewed 15

I have been creating a bot that uses tweepy; this has worked fine so far but after I updated my raspberry pi with the latest version of Raspbian to run it, I get an error:

UnicodeEncodeError: 'latin-1' codec can't encode character '\u26a1' in position 56: ordinal not in range(256)
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2026' in position 177: ordinal not in range(256)
UnicodeEncodeError: 'latin-1' codec can't encode character '\U0001f440' in position 37: ordinal not in range(256)

I have tried different ways of encoding it to utf-8 but then I just get an attribute error, presumably because it's an object unique to Tweepy.

Code:

list = self.client.get_list_tweets(list,
                        expansions="attachments.media_keys",
                        max_results=10)
print("list:", list.encode('UTF-8'))

Any ideas on how I could avoid this?

0 Answers
Related