前提
pythonでtweepyを使ってTwitterのアンフォローをしたいのですが、
api.destroy_friendship()でアンフォローする際にエラーになってしまいます。
TypeError: destroy_friendship() takes 1 positional argument but 2 were given
上記の引数に2つ値が設定されてる旨のメッセージが出てますが、
api.destroy_friendship(f) なので、引数は一つしか設定されていないはずです。
ご教示お願いいたします。
発生している問題・エラーメッセージ
Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1438, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/Users/tetetete/PycharmProjects/*/twitter/twitter_foro.py", line 24, in <module> api.destroy_friendship(f) File "/Users/tetetete/opt/anaconda3/lib/python3.7/site-packages/tweepy/api.py", line 46, in wrapper return method(*args, **kwargs) TypeError: destroy_friendship() takes 1 positional argument but 2 were given
該当のソースコード
followers = api.get_follower_ids() friends = api.get_friend_ids() unfollow_cnt = 0 for f in friends[::-1]: if f not in followers: if unfollow_cnt <= 1: api.destroy_friendship(f) print("{0}のフォローを解除しました。".format(api.get_user(f).screen_name)) unfollow_cnt += 1 else: break
補足情報(FW/ツールのバージョンなど)
Python3.7
回答1件
あなたの回答
tips
プレビュー