Python Twitter Unicode错误' UCS-2'

时间:2017-03-24 20:53:04

标签: python unicode bmp

当我尝试使用nltk或tweepy获取一些推文时,您好。我收到类似的错误

>>> from nltk.twitter import Twitter
>>> tw = Twitter()
>>> tw.tweets(keywords='love', limit=50)

推文输出

RT @BookOProverbs: Love your neighbor as yourself. -Mat 22:37
    RT @davebernstein: Dear @SpeakerRyan & @GOP:

You had 8 years– 8 years to come up with a replacement to #ACA.

ERROR

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    tw.tweets(keywords='love', limit=50)

  File "C:\Python\lib\site-packages\nltk\twitter\twitterclient.py", line 380, in tweets
    self.streamer.filter(track=keywords, follow=follow, lang=lang)

  File "C:\Python\lib\site-packages\nltk\twitter\twitterclient.py", line 118, in filter
    self.statuses.filter(track=track, follow=follow, lang=lang)

  File "C:\Python\lib\site-packages\twython\streaming\types.py", line 66, in filter
    self.streamer._request(url, 'POST', params=params)

  File "C:\Python\lib\site-packages\twython\streaming\api.py", line 154, in _request
    if self.on_success(data):  # pragma: no cover

  File "C:\Python\lib\site-packages\nltk\twitter\twitterclient.py", line 73, in on_success
    self.handler.handle(data)

  File "C:\Python\lib\site-packages\nltk\twitter\twitterclient.py", line 404, in handle
    print(text)

UnicodeEncodeError: 'UCS-2' codec can't encode characters in position 29-29: Non-BMP character not supported in Tk

0 个答案:

没有答案