python下载网络文件到本地

Posted xiandedanteng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python下载网络文件到本地相关的知识,希望对你有一定的参考价值。

# 下载网络图片文件到本地
import urllib.request

rsp=urllib.request.urlopen("http://n.sinaimg.cn/ent/transform/w630h933/20171222/o111-fypvuqf1838418.jpg")
img=rsp.read()
with open(1.jpg,wb) as f:
    f.write(img)

 

以上是关于python下载网络文件到本地的主要内容,如果未能解决你的问题,请参考以下文章