python 下载图片

def downloadImage(url):

    local_filename = url.split('/')[-1]


    r = requests.get(url, stream=True)

    with open(local_filename, 'wb') as f:

        for chunk in r.iter_content(chunk_size=1024):

            if chunk:

                f.write(chunk)

    return local_filename


你可能感兴趣的:(python 下载图片)