我收到此错误:
TypeError: user_followers() takes exactly 3 arguments (2 given)
在我的python脚本中,运行以下代码行:
origin = api.username_info('edelfilm')
user_id = origin['user']['pk']
followers = []
results = api.user_followers(user_id)
该函数在另一个脚本中定义如下:
def user_followers(self, user_id, rank_token, **kwargs):
"""
Get user followers
:param user_id:
:param rank_token: Required for paging through a single feed and can be generated with
:meth:`generate_uuid`. You should use the same rank_token for paging through a single user followers.
:param kwargs:
- **query**: Search within the user followers
- **max_id**: For pagination
:return:
"""
raise_if_invalid_rank_token(rank_token)
endpoint = 'friendships/{user_id!s}/followers/'.format(**{'user_id': user_id})
query_params = {
'rank_token': rank_token,
}
query_params.update(kwargs)
res = self._call_api(endpoint, query=query_params)
if self.auto_patch:
[ClientCompatPatch.list_user(u, drop_incompat_keys=self.drop_incompat_keys)
for u in res.get('users', [])]
return res
我做错了什么?
答案 0 :(得分:1)
首先在代码中定义变量rank_token
origin = api.username_info('edelfilm')
user_id = origin['user']['pk']
rank_token = 1 #Assuming it takes an integer value
followers = []
然后将其作为第三个参数传递给您的方法
results = api.user_followers(user_id, rank_token)