Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我怎样才能限制我想下载的推文?_Python_Time_Twitter_Tweets_Twython - Fatal编程技术网

Python 我怎样才能限制我想下载的推文?

Python 我怎样才能限制我想下载的推文?,python,time,twitter,tweets,twython,Python,Time,Twitter,Tweets,Twython,我下载了我想要的推文,但我的代码运行无限。谷歌协作环境说我不能中断代码。如何在不取消代码的情况下停止代码的运行? 这是我的密码:(拉格库西斯是希腊政治家) 打印(len(tweetsL),“tweets”)如果要根据列表长度设置限制,只需在while循环中添加以下内容: 如果len(tweetL)>1000: 打破 您可以使用您选择的限制替换值1000 while len(ragkousis) != 0: try: ragkousis = twitter.get_user_timeline

我下载了我想要的推文,但我的代码运行无限。谷歌协作环境说我不能中断代码。如何在不取消代码的情况下停止代码的运行? 这是我的密码:(拉格库西斯是希腊政治家)


打印(len(tweetsL),“tweets”)

如果要根据列表长度设置限制,只需在while循环中添加以下内容:

如果len(tweetL)>1000:
打破
您可以使用您选择的限制替换值
1000

while len(ragkousis) != 0:
try:
  ragkousis = twitter.get_user_timeline(screen_name= 'gragkousis',  count=100, tweet_mode = 'extended', exclude_replies = 'true', exclude_retweets = 'true')
except:                                              
    print("Error getting tweets:")
if len(ragkousis) > 0:
    print("I Got:", len(ragkousis), " tweets more... Last ID:", ragkousis[len(ragkousis)-1]['id']-1)
for tweet in ragkousis and voridis:
    tweetsL.append(tweet)