0

i think i have a problem with encoding, but i cant find the way to use encode/encoding on that case. i have this error wehn printing the code

Traceback (most recent call last):
  File "C:\Users\user\Desktop\python\twitter_bot\lesoons\print_tweets.py", line 21, in <module>
    print (tweets)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\encodings\cp1255.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 1188-1190: character maps to <undefined>
[Finished in 1.5s]
import tweepy
from api_keys import *


auth = tweepy.OAuth1UserHandler(
   consumer_key, consumer_secret, access_token,access_token_secret)

api = tweepy.API(auth, wait_on_rate_limit=True)





tweets = api.user_timeline(
       screen_name='@elonmusk',
       count=200, 
       include_rts = False,
       tweet_mode = 'extended')


print (tweets)
jojo_hal
  • 21
  • 6
  • Provide the full traceback please – puncher Aug 21 '22 at 09:39
  • Traceback (most recent call last): File "C:\Users\user\Desktop\python\twitter_bot\lesoons\print_tweets.py", line 21, in print (tweets) File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\encodings\cp1255.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 1188-1190: character maps to [Finished in 1.5s] – jojo_hal Aug 21 '22 at 09:55
  • Does this answer your question? [UnicodeEncodeError: 'charmap' codec can't encode characters](https://stackoverflow.com/questions/27092833/unicodeencodeerror-charmap-codec-cant-encode-characters) – Raja G Aug 21 '22 at 10:03
  • i have tried print (tweets.encode('utf-8') , but its not helping and i dont want to save it as a file just to print it – jojo_hal Aug 21 '22 at 10:07

0 Answers0