使用'twython'时发生错误

时间:2013-04-23 19:01:45

标签: python twitter twitter-oauth twython

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

>>> 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与消费者密钥相同,请告诉我? 请帮忙。

由于

1 个答案:

答案 0 :(得分:2)

请参阅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

相关问题