python - python3 encode errors, confusion (using twython) -


this first time trying out python in long time. trying extract , print tweets console using twython.

tw = twython(app_key, access_token=access_token) search = tw.search(q='#python') tweet in search["statuses"]:     print(tweet['user']['name'])     print(tweet['text']) 

usually few tweets print , run this, while printing either user name or tweet text (varies depending on character occurs):

unicodeencodeerror: 'charmap' codec can't encode character '\u2026' in position 139: character maps

i have tried adding .encode('utf-8') or wrapping in str(), closest b'text here', want tweet text. tried tacking on decode(). read have tell python kind of charset want encode, have been doing, still b'string here'. alot of examples find on web not python3 makes little more difficult find need.

can point me in right direction?

what character set used of console? assume it's ascii. '\u2026' legal character in utf-8 , illegal in ascii.
when print string, python try encode console's default character set since string stored unicode sequence internally. kind of error encountered occurs if characters in string not supported default character set.
can change locale lang utf-8 , run script again, btw, unicode character '\u2026' displayed "…".


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -