Yuu8599 2022-07-28 10:09 采纳率: 100%
浏览 103
已结题

关于python的json文件读取和统计

import json
f = open("pokemon_data.json","r",encoding="utf_8")
dat = json.load(f)
cnt = 0
lst = []
if i in range ["speed"]:
cnt += 1
lst.append(["name"])
print(f"速度大于100的宝可梦有{lst}")
print(lst)

请问要如何才能统计输出下列json数据中speed大于100的名字。

部分json数据如下
{
"name": "1",
"isMegaEvolution": true,
"evolutions": [],
"hiddenAbilities": [],
"stats": {
"hp": 97,
"attack": 167,
"defence": 97,
"spAttack": 167,
"spDefence": 97,
"speed": 129
}
},
{
"name": "2",
"form": "",
"isMegaEvolution": false,
"evolutions": [],
"hiddenAbilities": [],
"stats": {
"hp": 80,
"attack": 95,
"defence": 115,
"spAttack": 130,
"spDefence": 115,
"speed": 65
}
},
{
"name": "3",
"form": "",
"isMegaEvolution": false,
"evolutions": [],
"hiddenAbilities": [],
"stats": {
"hp": 90,
"attack": 125,
"defence": 80,
"spAttack": 90,
"spDefence": 90,
"speed": 125
}
},
{
"name": "4",
"form": "",
"isMegaEvolution": false,
"evolutions": [804],
"hiddenAbilities": [],
"stats": {
"hp": 67,
"attack": 73,
"defence": 67,
"spAttack": 73,
"spDefence": 67,
"speed": 73
}
},
{
"name": "5",
"form": "",
"isMegaEvolution": false,
"evolutions": [],
"hiddenAbilities": [],
"stats": {
"hp": 73,
"attack": 73,
"defence": 73,
"spAttack": 127,
"spDefence": 73,
"speed": 121
}
},
{
"no": 6,
"form": "",
"isMegaEvolution": false,
"evolutions": [],
"hiddenAbilities": [],
"stats": {
"hp": 61,
"attack": 131,
"defence": 211,
"spAttack": 53,
"spDefence": 101,
"speed": 13
}
},
{
"name": "7",
"form": "",
"isMegaEvolution": false,
"evolutions": [],
"hiddenAbilities": [],
"stats": {
"hp": 53,
"attack": 127,
"defence": 53,
"spAttack": 151,
"spDefence": 79,
"speed": 107
}
},
{
"name": "8",
"form": "",
"isMegaEvolution": false,
"evolutions": [],
"hiddenAbilities": [],
"stats": {
"hp": 88,
"attack": 112,
"defence": 75,
"spAttack": 102,
"spDefence": 80,
"speed": 143
}
}
]

  • 写回答

3条回答 默认 最新

  • 快乐小土狗 2022-07-28 13:26
    关注

    你知道循环的是个啥呀

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 8月5日
  • 已采纳回答 7月28日
  • 创建了问题 7月28日

悬赏问题

  • ¥15 关于将inet引入的相关问题
  • ¥15 关于一个倒计时的操作和显示设计
  • ¥15 提问STK的问题,哪位航天领域的同学会啊
  • ¥15 苹果系统的mac m1芯片的笔记本使用ce修改器使用不了
  • ¥15 单相逆变的电压电流双闭环中进行低通滤波PID算法改进
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 如何卸载arcgis 10.1 data reviewer for desktop
  • ¥15 共享文件夹会话中为什么会有WORKGROUP
  • ¥15 关于#python#的问题:使用ATL02数据解算光子脚点的坐标(操作系统-windows)
  • ¥115 关于#python#的问题:未加密前两个软件都可以打开,加密后只有A软件可打开,B软件可以打开但读取不了数据