调用:urllib.urlopen(url)

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

原因:

1,官方文档的解释:

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

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

2,正确的使用方法:

import urllib.request
url = "http://www.baidu.com"
get = urllib.request.urlopen(url).read()
print(get)

 

相关文章:

  • 2021-12-01
  • 2021-11-12
  • 2022-01-30
  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-12
  • 2021-07-18
  • 2022-01-15
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案