以下是json文件数据:
{
"a": [
{
"incl": "34.86"
},
{
"excl": "34.86"
},
{
"m": "tb"
},
...
]
"b": [
{
"incl": "24.86"
},
{
"excl": "14.86"
},
...
]
...
}
这是json文件的示例,
我想通过incl或excl获取前n个项(例如,“ a”,“ b”),该怎么做?
谢谢
We use
sorted()
here, which returns a list of the keys in the desired order.For top
n
keys byincl
:For top
n
keys byexcl
:注意:
d
is the json