簡體   English   中英

Tweepy 錯誤“API”object 沒有屬性“我”

[英]Tweepy error 'API' object has no attribute 'me'

我正在嘗試在 Replit 上運行來自https://github.com/CreepyD246/Twitter-Reply-Bot/blob/main/TwitterReplyBot.py的代碼。

#Importing modules/libraries
import tweepy
import time
import os

# Initialization code
auth = tweepy.OAuthHandler(os.getenv("key2"),os.getenv("skey2"))
auth.set_access_token(os.getenv("token2"),os.getenv("stoken2"))
api = tweepy.API(auth)

# Some important variables which will be used later
bot_id = int(api.me().id_str)
#Other things after

但我收到此錯誤:

Traceback (most recent call last):
File "main.py", line 12, in <module>
bot_id = int(api.me().id_str)
AttributeError: 'API' object has no attribute 'me'

我在 Tweepy 的文檔中沒有找到任何關於API.me()的信息,這是怎么回事? Tweepy 版本是 4.1.0。

Tweepy v4.0.0刪除API.me 您可以改用API.verify_credentials

這對我來說也很好。

Tweepy v4.0.0 移除API.me使用API.get_user即為現在的替代品

是的api.get_user是 tweepy v4.0.0 中的替代品

這對我api.get_user(screen_name="replaceWithYourTwitterUsername")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM