Python中的IRC连接问题

2024-04-25 08:09:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个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}$

Tags: py脚本消息mostdbirc错误line
1条回答
网友
1楼 · 发布于 2024-04-25 08:09:12

当连接关闭(EOF)时,ircsock.recv(4096)返回一个空字符串。反过来,''.split()返回空列表。尝试从空列表中获取第一个项目[][0]会引发IndexError。在

相关问题 更多 >