python 3.X版本是不需要安装:urllib2包的,urllib和urllib2包集合成在一个包了
那现在问题是:
在python3.x版本中,如何使用:urllib2.urlopen()?

答:
import urllib.request
resp=urllib.request.urlopen(http://www.baidu.com)
来源:https://www.cnblogs.com/zdlfb/p/6130724.html

附:

Python2 urllib2 与 Python3 urllib.request API对照

urllib2.urlopen()urllib.request.urlopen()
urllib2.install_opener()urllib.request.install_opener()
urllib2.build_opener()urllib.request.build_opener()
urllib2.URLErrorurllib.error.URLError
urllib2.HTTPErrorurllib.error.HTTPError
urllib2.Requesturllib.request.Request
urllib2.OpenerDirectorurllib.request.OpenerDirector
urllib2.BaseHandlerurllib.request.BaseHandler
urllib2.HTTPDefaultErrorHandlerurllib.request.HTTPDefaultErrorHandler
urllib2.HTTPRedirectHandlerurllib.request.HTTPRedirectHandler
urllib2.HTTPCookieProcessorurllib.request.HTTPCookieProcessor
urllib2.ProxyHandlerurllib.request.ProxyHandler
urllib2.HTTPPasswordMgrurllib.request.HTTPPasswordMgr
urllib2.HTTPPasswordMgrWithDefaultRealmurllib.request.HTTPPasswordMgrWithDefaultRealm
urllib2.AbstractBasicAuthHandlerurllib.request.AbstractBasicAuthHandler
urllib2.HTTPBasicAuthHandlerurllib.request.HTTPBasicAuthHandler
urllib2.ProxyBasicAuthHandlerurllib.request.ProxyBasicAuthHandler
urllib2.AbstractDigestAuthHandlerurllib.request.AbstractDigestAuthHandler
urllib2.HTTPDigestAuthHandlerurllib.request.HTTPDigestAuthHandler
urllib2.ProxyDigestAuthHandlerurllib.request.ProxyDigestAuthHandler
urllib2.HTTPHandlerurllib.request.HTTPHandler
urllib2.HTTPSHandlerurllib.request.HTTPSHandler
urllib2.FileHandlerurllib.request.FileHandler
urllib2.FTPHandlerurllib.request.FTPHandler
urllib2.CacheFTPHandlerurllib.request.CacheFTPHandler
urllib2.UnknownHandlerurllib.request.UnknownHandler
05-21 02:43