- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想在 Twitter 中打印所有关注者或关注者:
while True:
try:
for user in tweepy.Cursor(api.followers,screen_name='TestUser').items():
print user.screen_name
break
except tweepy.TweepError:
time.sleep(60*20)
当我运行这部分时,它会 try catch 以下内容。在我的线程中捕获的用户数是 200。但它在 20 分钟休眠后不会继续......它会尝试但会再次捕获用户。
我该如何解决?
最佳答案
每次在 for user in...
行中创建新的迭代器时,每次 while 循环迭代都会重新开始。
尝试使用生成器:
def handle_errors(cursor):
while True:
try:
yield cursor.next()
except tweepy.TweepError:
time.sleep(20 * 60)
for user in handle_errors(tweepy.Cursor(api.followers,screen_name='TestUser').items()):
print user.screen_name
关于python - 在 tweepy 中捕获所有追随者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33892529/
Mongoid 在 habtm 上带有 .push,它在两个方向上设置了 habtm 关系。尽管删除会#delete 关联记录,但没有记录的方法可以仅删除我所见过的关系。有没有更好的方法来做到这一点?
如何高亮系统光标?就像许多屏幕录制应用程序一样。理想情况下,我想在它周围显示一个光环。 最佳答案 对于纯托管解决方案,以下代码将在当前鼠标光标位置的桌面上绘制一个椭圆。 Point pt = Curs
我了解基本数据库关系的工作原理,但我对 RDBM 中的关注/关注者社交媒体关系感到困惑。 用户表: userId (PK) email name 如下表: followerId (FK referen
我正在设计一个应用程序,让用户“关注”彼此的事件,在 Twitter 的意义上,但我在数据库/查询设计/效率方面不是很有经验。是否有管理此问题的最佳实践、应避免的陷阱等?我收集到如果没有正确完成(或者
我正在尝试在 laravel 中制作一个简单的关注者/关注系统,没什么特别的,只需单击一个按钮即可关注或取消关注,并显示关注者或关注你的人。 我的问题是我不知道如何建立模型之间的关系。 这些是迁移:
所以我正在使用 mongodb,我不确定我是否有正确/最好的数据库集合设计来完成我正在尝试做的事情。 可以有很多项目,用户可以用这些项目创建新组。任何用户都可以关注任何组! 我不仅将关注者和项目添加到
我是一名优秀的程序员,十分优秀!