Python3.x:关于urllib中urlopen报错问题的解决方案

Python3.x:关于urllib中urlopen报错问题的解决方案

调用:urllib.urlopen(url)

报错:AttributeError: 'module' object has no attribute 'urlopen'

原因:

1,官方文档的解释:

      

官方3.0版本已经把urllib2,urlparse等五个模块都并入了urllib中,也就是整合了。

2,正确的使用方法:

import urllib.request
url = "http://www.baidu.com"
get = urllib.request.urlopen(url).read()
print(get)
原文地址:https://www.cnblogs.com/lizm166/p/8094919.html