【发布时间】:2014-10-06 13:09:45
【问题描述】:
我编写了一个使用 Twython 与 twitter 交互的 python 脚本。它将关注者列表下载到一个变量(关注者)中,并将我关注的人列表下载到另一个变量(朋友)中。然后它应该自动关注所有关注我但我尚未关注的人。
for fol in followers:
if fol not in friends:
twitter.create_friendship(fol)
我得到的错误是twitter.create_friendship 只需要一个参数,但它被赋予了两个。我看不出它是如何被赋予两个参数的,我只能看到一个。
【问题讨论】:
-
这是
create_friendship的文档,它指向friendships.create文档。 -
当你在python中调用一个函数时,你调用它的对象作为第一个参数传递。这就是为什么所有类方法都将
self作为第一个参数。
标签: python loops for-loop twython notin