python调用天气接口并解析json数据

"""
使用python调用请求
使用pip install requests安装requests
"""
import json

import requests

resp = requests.get(
    url='https://apis.tianapi.com/tianqi/index',
    params={'key': '4a9ce7c2516a223ewe323dwe323ew323eq1', 'city': '101020100', 'type': 1}
)
dict = json.loads(resp.text)
print(dict)
new_dict = dict['result']
print(new_dict)
date = new_dict['date']
week = new_dict['week']
print(date)
print(week)
上一篇:使用seq2seq架构实现英译法


下一篇:OrangePi AIpro Ubuntu 22.04 aarch64 安装MySql 8.0