为什么我保存的图片只有一张?
# -*- coding: UTF-8 -*- import urllib2 import re req = urllib2.urlopen('http://www.imooc.com/course/list?c=python') buf =req.read() listurl = re.findall(r'http://img.+.jpg',buf) print listurl i = 0 for url in listurl: file = open('D:/python/i'+'.jpg','w') req = urllib2.urlopen(url) buf = req.read() file.write(buf) i += 1