我想根据主题标签获取推文。但我得到以下错误。
>>> 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与消费者密钥相同,请告诉我? 请帮忙。
由于
答案 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
。