python使用urllib2 http 下载参数的try catch

import urllib2

req = urllib2.Request('http://blog.csdn.net/cqcre')
try:
urllib2.urlopen(req)
except urllib2.HTTPError, e:
print e.code
print e.reason

posted @ 2018-06-09 23:08  oftenlin  阅读(669)  评论(0编辑  收藏  举报