py 文件下载---笔记

#!/usr/bin/env python
# -*- coding:utf-8 -*-

import requests

def download_image():
 url = "https://secsb.com/wp-content/uploads/2017/07/20170711212747.png"
 req = requests.get(url,stream=True)
 with open('demo.jpg','wb') as fd:
 for chunk in req.iter_content(128):
 fd.write(chunk)

download_image()