有人能帮我找出这个错误吗?
import pygeoip
gi = pygeoip.GeoIP('GeoIP.dat')
print gi.country_code_by_name('specificdownload.com')
Traceback (most recent call last):
File "<module1>", line 14, in <module>
File "build\bdist.win-amd64\egg\pygeoip\__init__.py", line 447, in country_code_by_name
addr = self._gethostbyname(hostname)
File "build\bdist.win-amd64\egg\pygeoip\__init__.py", line 392, in _gethostbyname
return socket.gethostbyname(hostname)
gaierror: [Errno 11001] getaddrinfo failed
那么,让我们问Python什么类型的异常:
印刷品:
所以我们需要捕捉
socket.gaierror
,就像这样:尽管还有一个问题,那就是} documentation ,上面说
gaierror
到底是什么?谷歌出现了the ^{所以GAI Error=Get Address Info Error。
相关问题 更多 >
编程相关推荐