python3报错:No module named 'urllib2'

匿名 (未验证) 提交于 2019-12-02 22:54:36

Python 3.3之后,urllib2改为urllib.response


Python 2.7 代码:

import urllib2   response = urllib2.urlopen('http://www.baidu.com/')   html = response.read()   print html   


Python 3.3 代码应该为:

import urllib.request response=urllib.request.urlopen('http://www.baidu.com') html=response.read() print(html)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!