我编写了一个python脚本,它使用Twython与twitter交互。它将关注者列表下载到一个变量(关注者)中,并将我跟踪的人列表下载到另一个变量(好友)中。然后,它应该自动跟随每一个跟踪我的人,但谁我还没有跟随。
for fol in followers:
if fol not in friends:
twitter.create_friendship(fol)我遇到的错误是,twitter.create_friendship只需要一个参数,但它被赋予了两个参数。我看不出这是如何给出两个论点,我只能看到一个。
发布于 2014-10-06 13:14:10
create_friendship()是一个绑定方法,这意味着它将只使用self参数。它不使用任何其他位置参数,但您正在传递fol,现在给它两个参数(self和fol)。
方法应该被传递关键字参数,而不是:
twitter.create_friendship(user_id=fol)如果fol是用户id,或者
twitter.create_friendship(screen_name=fol)如果fol是一个屏幕名。
https://stackoverflow.com/questions/26216934
复制相似问题