除了这个json对象中的列表之外,我似乎无法弄清楚如何添加所有内容。我不断收到的错误是ValueError: too many values to unpack (expected 2)

data = { k:v for (k, v) in organization_types_json if k != organization_types_json['organization_type_names']}


杰森:

{
    "is_active": 0,
    "is_delete": 1,
    "organization_type_names": [{
        "lang": "EN",
        "name": "Fire"
    }, {
        "lang": "FR",
        "name": "Feu"
    }]
}

最佳答案

您需要这样添加.items()

data = { k:v for (k, v) in organization_types_json.items() if k != 'organization_type_names'}


或全部提取并删除该项目。

d = dict(organization_types_json)
del d['organization_type_names']

08-28 09:47