当前第2页 返回上一页
方法三:
1 2 3 4 5 6 | import requests
print "downloading with requests"
url = 'http://www.jb51.net/test/demo.zip'
r = requests.get(url)
with open ( "demo3.zip" , "wb" ) as code:
code.write(r.content)
|
看起来使用urllib最为简单,一句语句即可。当然你可以把urllib2缩写成:
1 2 3 | f = urllib2.urlopen(url)
with open ( "demo2.zip" , "wb" ) as code:
code.write(f. read ())
|
相关推荐:
Python文件操作之合并文本文件内容方法介绍
以上就是python实现下载文件的三种方法_python的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
[译]the Python tutorial#input and output
Python怎么调用图像处理
Python怎么调用youget
Python数据类型之元组的详细介绍
Python大神用的9个实用技巧分享给你
Python如何安装matplotlib
怎么用Python画圆
Python的str强转int时遇到的问题
Python爬虫看哪本书
Python数据分析
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python实现下载文件的三种方法_python