【发布时间】:2016-07-04 15:16:45
【问题描述】:
我尝试通过我使用 Tkinter 制作的 GUI 使用套接字模块解析主机 这是代码的一部分,主要问题是我在解析路由器名称时收到的错误
for line in p.stdout:
fiw = open("1.txt", '+a')
line = str(line)
if "Received = 1" in line:
hostad = socket.gethostbyaddr(ip3 +str(i))
if hostad:
try:
print(hostad)
except socket.herror:
print(hostad)
fiw.write("Received reply from " + ip3 +str(i)+"\n")
print("Received reply from " + ip3 +str(i)+"\n")
print(socket.gethostbyaddr(ip3 +str(i)))
错误:
socket.herror: [Errno 11004] host not found
脚本不会进一步运行,我在这里使用了print,例如我也尝试过pass
试过了
except socket.herror as err:
print(err)
pass
也试过在这个方法中使用pass
【问题讨论】:
标签: python windows python-3.x networking tkinter