向来用urlopen就没成功过,各种Connectionrefused求解:源程序代码就两行:req=urllib2.Request("http://www.qq.com")fp=urllib2.urlopen(req)然后就是各种错误,如下:ERROR:Anunex...
向来用urlopen就没成功过,各种Connection refused 求解:
源程序代码就两行:
req = urllib2.Request("http://www.qq.com")
fp = urllib2.urlopen(req)
然后就是各种错误,如下:
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (119, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (141, 0))
---------------------------------------------------------------------------
URLError Traceback (most recent call last)
/home/hakz/ in ()
/usr/lib/python2.6/urllib2.pyc in urlopen(url, data, timeout)
124 if _opener is None:
125 _opener = build_opener()
--> 126 return _opener.open(url, data, timeout)
127
128 def install_opener(opener):
/usr/lib/python2.6/urllib2.pyc in open(self, fullurl, data, timeout)
389 req = meth(req)
390
--> 391 response = self._open(req, data)
392
393 # post-process response
/usr/lib/python2.6/urllib2.pyc in _open(self, req, data)
407 protocol = req.get_type()
408 result = self._call_chain(self.handle_open, protocol, protocol +
--> 409 '_open', req)
410 if result:
411 return result
/usr/lib/python2.6/urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
367 func = getattr(handler, meth_name)
368
--> 369 result = func(*args)
370 if result is not None:
371 return result
/usr/lib/python2.6/urllib2.pyc in http_open(self, req)
1159
1160 def http_open(self, req):
-> 1161 return self.do_open(httplib.HTTPConnection, req)
1162
1163 http_request = AbstractHTTPHandler.do_request_
/usr/lib/python2.6/urllib2.pyc in do_open(self, http_class, req)
1134 r = h.getresponse()
1135 except socket.error, err: # XXX what error?
-> 1136 raise URLError(err)
1137
1138 # Pick apart the HTTPResponse object to get the addinfourl
URLError:
不给力啊 求解!
呃 我重装了python还是不给力啊!悲剧
展开