擅长:python、mysql、java
<p><a href="http://docs.python.org/2/reference/simple_stmts.html#continue">^{<cd1>}</a>只允许在<code>for</code>或<code>while</code>循环中使用。您可以轻松地重新构造函数以循环,直到有一个有效的请求。</p>
<pre><code>def writeHandlesToFile():
while True:
with open("dataFile.txt","w") as f:
try:
lst = tweepy.Cursor(tweepy.api.followers,screen_name='someHandle',).items(100000)
print "cursor executed"
for item in lst:
f.write(item.screen_name+"\n")
break
except tweepy.error.TweepError as e:
print "In the except method"
print e
time.sleep(3600)
</code></pre>