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)