python 下载url图片

##下载url图片函数

import urllib
import urllib.request
def get_image(url,stuNum):
    try:
        request = urllib.request.Request(url)
        response = urllib.request.urlopen(request)
        get_img = response.read()
        with open('E:\\xiangmu\\fenlei1_9\\picture\\name'+str('%02d'%bianhao[i])+'_'+str(stuNum)+'.jpg','wb') as fp:
            fp.write(get_img)
            print('图片下载完成')
    except:
        print('访问空')

你可能感兴趣的:(python)