1 Star 0 Fork 0

laurus/python

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test3.py 299 Bytes
一键复制 编辑 原始数据 按行查看 历史
laurus 提交于 2022-05-01 11:23 +08:00 . 第九、十次作业提交
# 引用json库
import json
# 读取文件
file = open("天气预报json.txt", "rt", encoding="utf-8")
# 解码
str = json.load(file)
# 循环,输出前3项
for i in str["result"]["future"][0:3]:
# 输出温度和天气
print(i["temperature"], i["weather"])
# 关闭文件
file.close()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/laurus117/python.git
git@gitee.com:laurus117/python.git
laurus117
python
python
master

搜索帮助