gpt4 book ai didi

python - tweepy api.me() 不返回 friend 的用户对象

转载 作者:行者123 更新时间:2023-12-01 05:41:39 28 4
gpt4 key购买 nike

因此,从 tweepy 文档中,我应该能够使用 api.me() 来获取用户关注的 friend 列表:http://pythonhosted.org/tweepy/html/api.html#user-methods首先,我做了通常的 OAuth 舞蹈:

import tweepy
consumer_token='#####'
consumer_secret='$$$$$'
access_token='&&&&&'
access_token_secret='****'
auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth)
daysinn_friends=api.me('DaysInnCanada')

然后 python 给了我一个错误:

Traceback (most recent call last):
File "<pyshell#40>", line 1, in <module>
daysinn_friend=api.me('DaysInnCanada')
TypeError: me() takes exactly 1 argument (2 given)

但是我没有向 me() 传递 2 个参数,唯一的参数是 screen_name。我真的很困惑,想不通。谢谢

最佳答案

让您感到困惑的“额外”参数是 Python self 参数。我已经在 https://stackoverflow.com/a/16259484/2314532 中对 self 写了很长的解释,所以我不会重复它,而是直接向您指出该答案。如果读完后您仍然不明白发生了什么,请告诉我,我会看看是否可以进一步解释。

此外,查看 tweepy 的 API 文档,me() 应该不带任何参数,而您要向它传递一个参数。通过查看您的代码,我怀疑您真正想要做的是调用 api.followers("DaysInnCanada") 。或者也许api.get_user("DaysInnCanada"),但我怀疑您打算使用关注者

关于python - tweepy api.me() 不返回 friend 的用户对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17386934/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com