- 积分
- 2005
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-4-7
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2019-7-17 21:48:18
|
显示全部楼层
稍微修改了一下代码,看起来更简洁一点:
import requests
url1 = 'https://www.ncei.noaa.gov/data/global-precipitation-climatology-project-gpcp-monthly/access/'
for year in range(1985,2018):
for month in range(1,13):
if month < 10:
url = url1+ str(year) + '/gpcp_v02r03_monthly_d' + str(year) + '0' + str(month)+'_c20170616.nc'
r = requests.get(url)
with open("E:\\GPCP\\"+str(year)+'_0'+str(month)+".nc", "wb") as code:
code.write(r.content)
else:
url = url1 + str(year) + '/gpcp_v02r03_monthly_d' + str(year) + str(month) + '_c20170616.nc'
r = requests.get(url)
with open("E:\\GPCP\\"+str(year)+'_'+str(month)+".nc", "wb") as code:
code.write(r.content) |
|