【问题标题】:error occurring while using 'twython'使用“twython”时发生错误
【发布时间】:2013-04-24 04:17:25
【问题描述】:

我想根据主题标签获取推文。但我收到以下错误。

>>> import twython
>>> TWITTER_APP_KEY = 'xxxxxx'
>>> TWITTER_APP_KEY_SECRET = 'xxxxx'
>>> TWITTER_ACCESS_TOKEN = 'xxxxxx'
>>> TWITTER_ACCESS_TOKEN_SECRET = 'xxxxx'
>>> t = twython(app_key=TWITTER_APP_KEY, 
        app_secret=TWITTER_APP_KEY_SECRET, 
            oauth_token=TWITTER_ACCESS_TOKEN, 
            oauth_token_secret=TWITTER_ACCESS_TOKEN_SECRET)

Traceback (most recent call last):
  File "<pyshell#16>", line 4, in <module>
    oauth_token_secret=TWITTER_ACCESS_TOKEN_SECRET)
TypeError: 'module' object is not callable

不明白为什么会出现上述错误?另外请让我知道 app_key 是否与消费者密钥相同? 请帮忙。

谢谢

【问题讨论】:

    标签: python twitter twitter-oauth twython


    【解决方案1】:

    documentation

    from twython import Twython
    
    t = Twython(app_key=app_key,
                app_secret=app_secret,
                callback_url='http://google.com/')
    

    在您的示例中,您直接调用 模块 twython 而不是类 twyton.Twython

    要使您的示例正常工作,您需要将 import twython 替换为 from twython import Twython

    【讨论】:

      猜你喜欢
      • 2013-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-07
      相关资源
      最近更新 更多