API--天气查询(高德api)

下面为代码片段 ,仅作参考,获取的是今日的天气情况

	# # 天气查询--高德api
	url_api= "https://restapi.amap.com/v3/weather/weatherInfo?"
	extensions= "all"
	url_api+= "key="+key+ "&city="+ adcode+ "&extensions="+ extensions
	res= requests.get(url_api)
	res= json.loads(res.text)
	today= res["forecasts"][0]["casts"][0]
	print(str(today))
	return str(today)

 

你可能感兴趣的:(api,python)