Python 2.7.10 Win7(64位)操作系统URLE

2024-10-01 17:21:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用Python 2.7.10 Shell运行以下代码:

# encoding: utf8
import urllib2
import re
response=urllib2.urlopen("https://www.baidu.com/")
print response.read()

不幸的是,我得到了错误:

Traceback (most recent call last):
  File "C:\Users\Vivid\Desktop\LISA\datacrawling\ex.py", line 6, in <module>
    response=urllib2.urlopen("https://www.baidu.com/")
  File "D:\Program Files\Python2710\lib\urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "D:\Program Files\Python2710\lib\urllib2.py", line 431, in open
    response = self._open(req, data)
  File "D:\Program Files\Python2710\lib\urllib2.py", line 449, in _open
    '_open', req)
  File "D:\Program Files\Python2710\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "D:\Program Files\Python2710\lib\urllib2.py", line 1240, in https_open
    context=self._context)
  File "D:\Program Files\Python2710\lib\urllib2.py", line 1197, in do_open
    raise URLError(err)
URLError: <urlopen error [Errno 11004] getaddrinfo failed>

你对这个问题有什么看法吗?我被它缠住很久了…谢谢!你知道吗


Tags: inpyhttpsimportresponselibwwwline

热门问题