【发布时间】:2022-01-02 21:36:44
【问题描述】:
我想使用 tweepy 的 create_friendship 来关注特定帐户。 但我不断收到错误消息。
错误
File "twitter_retweet_by_word.py", line 20, in <module>
api.create_friendship("**********")
File "/Users/*****/opt/anaconda3/lib/python3.8/site-packages/tweepy/api.py", line 46, in wrapper
return method(*args, **kwargs)
TypeError: create_friendship() takes 1 positional argument but 2 were given
我在下面的链接中检查了类似的问题,但我不明白我必须做些什么才能使它工作。
Tweepy api: create_friendship() takes 1 positional argument but 2 were given
我的代码
import tweepy
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
# OAuth
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
for status in api.search_tweets(q='Python RT', count=2):
tweet_id = status.id
print(tweet_id)
user_id = status.user.screen_name
print(user_id)
api.create_friendship(user_id)
您能否告诉我我需要如何更改代码才能使其正常工作? 提前致谢。
python 版本:3.8.5 tweepy 版本:4.3.0
【问题讨论】: