【发布时间】:2018-06-21 12:11:28
【问题描述】:
所以我正在开发一个 Twitter 机器人,在异常期间我遇到了导致程序停止的错误。我不确定是什么原因造成的。
我一直在四处寻找试图弄清楚但没有运气。
任何人都可以发现问题。
except tweepy.error.TweepError as e:
error_code = list(e)[0][0].get('code')
if error_code == 327:
print('no need')
elif error_code == 88:
print('wait 16 minutes we have hit limit')
time.sleep(15 * 60)
elif error_code == 226:
print('STOP')
time.sleep(15 * 60)
elif error_code == 261:
print(' banned')
else:
print(str(e))
except AttributeError as e:
print('Something bad has happened')
except Error as e:
print(str(e))
它给我的错误如下:
error_code = list(e)[0][0].get('code')
TypeError: 'TweepError' object is not iterable
任何帮助都会很棒。
【问题讨论】:
-
可能是因为
list(e)失败了。为什么要将错误转换为列表? -
list(Exception)不起作用。你在看this answer吗? -
感谢您提供的链接 patrick,我现在将阅读它