程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

About python json file reading and statistics

編輯:Python

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"速度大於100Can be a dream{lst}")
print(lst)

Excuse me, how can statistical output the followingjson數據中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
}
}
]


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved