【发布时间】:2016-04-24 14:18:02
【问题描述】:
from socket import socket, AF_INET, SOCK_STREAM
sock = socket(AF_INET, SOCK_STREAM)
sock.bind(("localhost", 7777))
sock.listen(1)
while True:
try:
connection, address = sock.accept()
print("connected from " + address)
received_message = sock.recv(300)
if not received_message:
break
connection.sendall(b"hello")
except KeyBoardInterrupt:
connection.close()
所以我试图将我的头绕在套接字周围并拥有这个非常简单的脚本
但由于某种原因,我无法用 KeyboardInterrupt 杀死这个脚本
我如何用KeyboardInterrupt 杀死脚本,为什么我不能用KeyboardInterrupt 杀死它?
【问题讨论】: