小编iam*_*l4v的帖子

按字典值的值对字典进行排序

我目前有一些如下所示的 JSON:

{
    "Chile": {
        "num_of_unique_ips": 1,
        "num_of_unique_asns": 1,
        "asns": {
            "AS16629 CTC. CORP S.A. (TELEFONICA EMPRESAS)": 1
        }
    },
    "China": {
        "num_of_unique_ips": 1,
        "num_of_unique_asns": 1,
        "asns": {
            "AS4808 China Unicom Beijing Province Network": 1
        }
    }, # this goes on and on for ever country
}
Run Code Online (Sandbox Code Playgroud)

我通过运行将其转换为字典:

import json
login_by_country = json.loads(open('login_by_country.json', 'r'))
Run Code Online (Sandbox Code Playgroud)

我将如何按照每个国家/地区的值对这本词典进行排序num_of_unique_ips

python sorting dictionary

1
推荐指数
1
解决办法
90
查看次数

标签 统计

dictionary ×1

python ×1

sorting ×1