i = 0 for url in listurl: f = open(str(i)+'.jpg','w') req = urllib.request.urlopen(url) buf = req.read() buf = buf.decode('utf-8') f.write(buf) i+=1 出现UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte错误 求大神解答
decode(‘utf-8’, ‘ignore')
指明ignore,忽略非法字符
自己弄懂了 用f = open(str(i)+'.jpg','wb')就可以了