2016-04-21 56 views

回答

4

我也遇到了同样的错误,并谷歌搜索解决它。 urlib.request适用于Python 3.0。如果你有一台Windows计算机,其中easy_install可以在的Python * \ Scripts中找到文件夹,如果安装了它

import urllib 
urllib.urlopen(url) 
+0

请检查这个[URL](http://stackoverflow.com/help)它将有助于提高你的质量 –

-1

使用>Path\easy_install.exe请求:

您可以使用下面的代码。 (注意Path \ easy_install.exe就是一个例子,我的是C:\ Python32 \ Scripts \ easy_install.exe)

如果你没有简单的安装并且正在windows机器上运行,你可以在这里找到它: http://www.lfd.uci.edu/~gohlke/pythonlibs/#distribute

如果您手动将库添加到Windows机器,您可以下载压缩库,解压缩它,然后将其放到您的python路径的Lib文件夹中。

OR

您需要安装pip,然后再使用安装django-request PIP

pip install django-request 

同时安装,

python setup.py install 

然后导入

from urllib.request import urlopen 

Helpful Tips:to chech this

17

的urllib.request里的模块已过时.. 只使用

import urllib 

并为你的功能,如果你是早期作品说

urllib.request.urlretrieve 

现在,你只写

urllib.urlretrieve 
0

尝试在Python3中使用它

try: 
    x = urllib.request.urlopen('https://www.google.com/search?q=test') 
    print(x.read()) 

except Exception as e: 
    print(str(e)) 
相关问题