Python:无法修复获取tweet的索引错误

2024-05-18 18:37:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图将推文下载到csv中来训练机器人,但我被这个索引器卡住了。 错误在最后一行:

    def download_tweets(
username=None,
limit=None,
include_replies=False,
include_links=False,
strip_usertags=False,
strip_hashtags=False,

# If a limit is specificed, validate that it is a multiple of 20
if limit:
    assert limit % 20 == 0, "`limit` must be a multiple of 20."

# If no limit specifed, estimate the total number of tweets from profile.
else:
    c_lookup = twint.Config()
    c_lookup.Username = username
    c_lookup.Store_object = True
    c_lookup.Hide_output = True
    if include_links is True:
        c_lookup.Links = "include"
    else:
        c_lookup.Links = "exclude"

    twint.run.Lookup(c_lookup)
    limit = twint.output.users_list[-1].tweets

错误消息:在下载推文中 limit=twint.output.users\u list[-1]。tweets 索引器:列表索引超出范围


Tags: ofnonefalsetrueoutputincludeis错误

热门问题