我有一个Python脚本,它有一个无限while循环。它加入一个IRC通道,进行一些计算,打印一些消息,休眠5分钟,然后重复。脚本会定期出现以下错误:
Traceback (most recent call last):
File "db_alerts.py", line 65, in <module>
if data.split()[0].find('PING') != -1:
IndexError: list index out of range
IRC句柄离开通道时显示以下消息:(03:00:56 PM) TestBOT left the room (quit: Ping timeout: 121 seconds).
我的代码如下:
^{pr2}$
当连接关闭(EOF)时,
ircsock.recv(4096)
返回一个空字符串。反过来,''.split()
返回空列表。尝试从空列表中获取第一个项目[][0]
会引发IndexError
。在相关问题 更多 >
编程相关推荐