import os
os.makedirs('./image/', exist_ok=True)
IMAGE_URL = "http://image.nationalgeographic.com.cn/2017/1122/20171122113404332.jpg" def urllib_download():
from urllib.request import urlretrieve
urlretrieve(IMAGE_URL, './image/img1.png') def request_download():
import requests
r = requests.get(IMAGE_URL)
with open('./image/img2.png', 'wb') as f:
f.write(r.content) def chunk_download():
import requests
r = requests.get(IMAGE_URL, stream=True)
with open('./image/img3.png', 'wb') as f:
for chunk in r.iter_content(chunk_size=32):
f.write(chunk) urllib_download()
print('download img1')
request_download()
print('download img2')
chunk_download()
print('download img3')

最新文章

  1. [Java] Spring MVC 知识点
  2. SQLite学习笔记(七)&&事务处理
  3. 当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'OrderList' 中的标识列插入显式值
  4. java服务器端编程
  5. (二)cordova+framework7入门——笑笑APP
  6. BackTrack5-r3硬盘安装
  7. Effective Java 阅读笔记——枚举和注解
  8. EasyUI tab常用
  9. mvc4帮助类
  10. vmware 几种联网的方式,怎样实现虚拟机上网
  11. struts2 convention-plugin
  12. Physiological Processes of Speech Production--Reading Notes (8)
  13. openlayers应用(二):加载百度离线瓦片
  14. PHP 命名空间与自动加载机制
  15. 在windows 下使用eclipse进行编译和烧写
  16. sqlserver2008 链接服务器 2000
  17. JDK8中JVM堆内存划分
  18. C++ string中的几个小陷阱,你掉进过吗?
  19. 大数据系列之数据仓库Hive原理
  20. WCF系列教程之WCF客户端调用服务

热门文章

  1. Promise如何解决回调地狱
  2. Spring Session工作原理
  3. PriorityBlockingQueue
  4. Disruptor系列(三)— 组件原理
  5. C# ICloneable,shallow clone,deep clone.
  6. Mac设置su root密码
  7. Flask 教程 第四章:数据库
  8. Hystrix失败处理逻辑解析
  9. CSS3 新增选择器
  10. CSS字体属性