import tweepy
import json
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ''
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
twitter_api = tweepy.API(auth)
# I made a dict of different countries and their WOE_ID...
PLACE_WOE_ID = country_id[country]
place_trends = twitter_api.trends.place(_id=PLACE_WOE_ID)
每次我运行代码时,都会出现以下错误。我在stackoverflow上检查了有关Twitter API的其他帖子,但还没有找到解决方案。
Traceback (most recent call last):
File "C:/Users/user/Documents/twipgm.py", line 44, in <module>
place_trends = twitter_api.trends.place(_id=PLACE_WOE_ID)
AttributeError: 'API' object has no attribute 'trends'
答案 0 :(得分:2)