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.request
resp=urllib.request.urlopen('http://www.baidu.com')
html=resp.read()
print(html)

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

posted @ 2016-05-24 10:37  御剑之道  阅读(807)  评论(0编辑  收藏  举报