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

关于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日

悬赏问题

  • ¥50 Delphi5环境下图片文件怎么转换成Base64编码?
  • ¥15 久了用Python,今天打开PyCharm就这样了
  • ¥15 将GPDO_0引|脚设首成PWM1的输出引脚 实验编程该怎么写
  • ¥50 阿里云服务器 CentOS7.9 搭建 openvpn 服务
  • ¥100 开源软件弱点处理规范
  • ¥15 excel如何根据文件名自动搜索并批量导入文件?
  • ¥15 VScode 用户代码片段图标
  • ¥15 streamingtool
  • ¥15 MATLAB图像问题
  • ¥20 树莓派5做人脸情感识别与反馈系统