open python error_关于python 的一个urlopen Error

向来用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还是不给力啊!悲剧

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值