如何忽略ConnectionRefusedError?

时间:2018-10-04 15:56:22

标签: python-3.x sockets

所以我想做一个不断发送连接请求的程序,如下所示:

while True:
    try:
        client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        client.connect(ADDR)
        time.sleep(30)
    except Exception:
        print("Error")

但是,即使我将代码缩进了TRY EXCEPT上,它也不会忽略此错误。

  

ConnectionRefusedError:[WinError 10061]

为什么在TRY EXCEPT上缩进后会出现这种情况?

非常感谢。

0 个答案:

没有答案