python 3.3.2报错:No module named 'urllib2'

ModuleNotFoundError: No module named 'urllib3'

1. ImportError: No module named 'cookielib'1

Python3中,改成 import  http.cookiejar,然后方法里也改成 http.cookiejar,查找替换就行

2. NameError: name 'raw_input' is not defined
在版本3中已经用input()替换


3. Import error: No module name urllib
from urllib.request import urlopen


4. ImportError: No module named urllib2
Python 3中urllib2用urllib.request替代

在Python官方文档里面已有说明:

Note
The urllib2 module has been split across several modules in Python 3.0 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to 3.0.
from urllib.request import urlopen
response = urlopen("http://www.google.com")
html = response.read()
print(html)
sample:
import urllib.request
resp=urllib.request.urlopen('http://www.baidu.com')
html=resp.read()
print(html)
原文地址:https://www.cnblogs.com/zangdalei/p/8268955.html