我正在使用 twython 从 twitter 获取一些推文。要获取我使用 try / except 的推文,例如
for follower in followers_file_id:
follower = follower.strip()
try:
if req_user_settings > max_user_settings_req or req_user_tweets > max_tweets_req:
time.sleep(15 * 60)
tweets_file_name = tweetsFileName(followed_user)
user_settings = twitter.show_user(user_id = follower)
req_user_settings += 1
if not user_settings['protected'] and user_settings['statuses_count'] > 0:
tweets = twitter.get_user_timeline(user_id = follower, count = 200, page = 1)
req_user_tweets += 1
n_tweets =tweets[0]['user']['statuses_count']
n_loops = n_tweets // max_tweets_per_page + 1
if n_loops > max_tweet_pages:
n_loops = max_tweet_pages
if tweets[0]['user']['lang'] == 'en':
n_crawled_tweets = writeTweets(tweets, tweets_file_name, n_crawled_tweets)
for i_loop in range(1, n_loops):
tweets = twitter.get_user_timeline(user_id = follower, count = 200, page = i_loop+1)
n_crawled_tweets = writeTweets(tweets, tweets_file_name, n_crawled_tweets)
req_user_tweets += 1
except TwythonError as e:
print str(e)
打印错误后如何告诉程序继续执行?原因现在打印错误后,程序停止。