|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
刚学python爬虫,在运行最简单的程序,然而报错了,goole了一下,什么也没找到,,
代码:
- import urllib.request
- response = urllib.request.urlopen('http://www.python.org')
- print(response.read().decode('utf_8'))
复制代码
报错信息:
- Traceback (most recent call last):
- File "E:\python\lib\http\client.py", line 877, in _get_hostport
- port = int(host[i+1:])
- ValueError: invalid literal for int() with base 10: '1080;DIRECT'
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "E:\devc++\atom\python\《head_first_python》笔记\推导数据\text.py", line 3, in <module>
- response = urllib.request.urlopen('http://www.python.org')
- File "E:\python\lib\urllib\request.py", line 222, in urlopen
- return opener.open(url, data, timeout)
- File "E:\python\lib\urllib\request.py", line 525, in open
- response = self._open(req, data)
- File "E:\python\lib\urllib\request.py", line 543, in _open
- '_open', req)
- File "E:\python\lib\urllib\request.py", line 503, in _call_chain
- result = func(*args)
- File "E:\python\lib\urllib\request.py", line 1345, in http_open
- return self.do_open(http.client.HTTPConnection, req)
- File "E:\python\lib\urllib\request.py", line 1285, in do_open
- h = http_class(host, timeout=req.timeout, **http_conn_args)
- File "E:\python\lib\http\client.py", line 841, in __init__
- (self.host, self.port) = self._get_hostport(host, port)
- File "E:\python\lib\http\client.py", line 882, in _get_hostport
- raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
- http.client.InvalidURL: nonnumeric port: '1080;DIRECT'
复制代码
我是用atom的python插件运行的,奇怪的是同样的代码在python IDLE,和命令行中都能运行,
插件是atom-python-run
求大佬解答 |
|