Python:无法修复此索引错误以获取推文

问题描述

我正在尝试将推文下载到 csv 中以训练机器人,但我遇到了这个 Indexerror。 错误在最后一行:

    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_list[-1].tweets 索引错误:列表索引超出范围

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)