python3报错:No module named 'urllib2'
程序员文章站
2022-05-28 22:26:41
...
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)
(资料来自SegmentFault)
上一篇: 6大设计原则之单一职责原则
下一篇: 每日一题(字符串拆分)
推荐阅读
-
下载python中Crypto库报错:ModuleNotFoundError: No module named ‘Crypto’的解决
-
下载python中Crypto库报错:ModuleNotFoundError: No module named ‘Crypto’的解决
-
解决方法:在Python中使用Win32api报错的问题,No module named win32api
-
Python3中无法导入ssl模块的解决办法和python3.7 ModuleNotFoundError: No module named bz2解决办法
-
Django重装mysql后启动报错:No module named ‘MySQLdb’的解决方法
-
Centos7 执行firewall-cmd –permanent –add-service=mysql报错“ModuleNotFoundError: No module named 'gi'”
-
Linux—运行yum报错:No module named yum
-
PyCharm导入pymysql包运行报错问题解决:No module named 'PyMySQL'
-
【昊鼎王五】执行python3脚本,报“ModuleNotFoundError: No module named 'dateutil'”错的解决方法
-
解决pycharm终端/cmd运行python脚本报错“ImportError/ModuleNotFoundError:No Module named ...”