首页 历史天气 历史天气示例代码 历史天气查询[Python]

历史天气查询示例代码Python

作者: 阅读数:1138 上传时间:2025-03-28

历史天气查询

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

import requests
data = {}
data["appkey"] = "your_appkey_here"
data["city"]="安顺"
data["cityid"]="111"
data=data
url=" https://api.jisuapi.com/weather2/query"
response = requests.post(url, params=data)
jsonarr = response.json()
if jsonarr["status"] != 0:
    print(jsonarr["msg"])
    exit()
result= jsonarr["result"]
print(result["cityid""cityid"],result["date"],result["weather"],result["temphigh"],
      result["templow"],result["img"],result["humidity"],result["pressure"],result["windspeed"],
      result["winddirect"],result["windpower"],result["sunrise"],result["sunset"],
      result["aqi"],result["primarypollutant"],result["cityname"])