我编写了以下代码来获取用户名拥有的所有 Twitter 关注者的列表,但我想只获取 user_id,因为这允许我在 API 的速率限制内做更多的事情。如何更改此代码以仅打印 user_ids?
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(key, secret)
api = tweepy.API(auth)
screen_name = "twitterusername"
friends = api.friends_ids(screen_name)
print(screen_name + " is following :")
for friend in friends:
print(api.get_user(friend).screen_name)
我拥有所有正确的授权密钥和令牌。