No module named 'urllib2'

No module named 'urllib2'

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

报错

import urllib2

ImportError: No module named 'urllib2'


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

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

你可能感兴趣的:(No module named 'urllib2')