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

报错

import urllib2
ImportError: No module named 'urllib2'

 

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

在python3.3里面,用urllib.request代替urllib2

相关文章:

  • 2021-11-29
  • 2022-12-23
  • 2021-10-10
  • 2021-04-10
  • 2022-01-04
  • 2021-11-21
  • 2022-12-23
  • 2021-07-06
猜你喜欢
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案