首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python-twitter stream提升JSONDecodeError

python-twitter stream提升JSONDecodeError
EN

Stack Overflow用户
提问于 2020-04-30 23:17:45
回答 1查看 47关注 0票数 0

当使用next()调用流的下一条tweet时,出现以下错误。当我尝试使用相同的twitter API对象调用其他函数时,比如GetFriends(),它工作得很好。任何帮助都是非常感谢的!

下面是错误:

代码语言:javascript
复制
Traceback (most recent call last):
 File "/usr/local/lib/python3.8/site-packages/twitter/api.py", line 4897, in _ParseAndCheckTwitter
    data = json.loads(json_data)
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

下面是代码:

代码语言:javascript
复制
import twitter
class Topic:
    def __init__(self, topic):
        self.api = self.get_twitter_api()
        self.stream = self.api.GetStreamFilter(track=[topic])
        self.count_tweets()

    def get_twitter_api(self):
        with open('/twitter_credentials.json') as f:
            return twitter.Api(**eval(f.read()))

    def count_tweets(self):
        while next(self.stream):
            print("tweet")
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-07 14:25:16

书中最古老的诀窍奏效了:重启电脑。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61526861

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档