Python 通过下载链接把文件下载到本地

#!/usr/bin/python
#encoding:utf-8

import requests

url = 'https://climate.northwestknowledge.net/TERRACLIMATE-DATA/TerraClimate_vpd_' + str(year) + '.nc'

file = "E:/PostDoc/Data/TEM/TerraClimate_vpd_" + str(year) + '.nc'

r = requests.get(url)
with open(file, "wb") as code:
    code.write(r.content)

 

posted @ 2020-04-04 21:44  sym0210  阅读(8337)  评论(0)    收藏  举报