【发布时间】:2018-02-11 17:59:06
【问题描述】:
我的代码是:
usso = socket.gethostbyname("site.com")
try:
usso
except socket.gaierror:
uss = 0
else:
uss = 1
if uss == 1:
print ("Site Is True")
elif uss == 0:
print ("Site Is Wrong")
但除了不工作,结果是:
Traceback (most recent call last):
File "test.py", line 22, in <module>
usso = socket.gethostbyname("site.com")
socket.gaierror: [Errno -2] Name or service not known
有什么问题?
【问题讨论】:
标签: python sockets try-catch except