2016-04-21 63 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)) 
相關問題