Python如何在不覆盖其他值的情况下更新dict

Python如何在不覆盖其他值的情况下更新dict,python,dictionary,Python,Dictionary,假设我有这个: config = { "a": { "hello": 1, "goodbye": 2, } } 我想将[“a”][“hello”]更新为10,如下所示: update = { "a": { "hello": 10 } } config.update(update) 此时,配置为: config = { "a": { "hello": 10 } } 如何用另一个d

假设我有这个:

config = {
    "a": {
        "hello": 1,
        "goodbye": 2,
    }
}
我想将
[“a”][“hello”]
更新为10,如下所示:

update = {
    "a": {
        "hello": 10
    }
}

config.update(update)
此时,配置为:

config = {
    "a": {
        "hello": 10
    }
}
如何用另一个dict更新一个dict而不覆盖其他值/子CT

config = {
    "a": {
        "hello": 1,
        "goodbye": 2,
    }
}
你可以做:

config['a']['hello'] = 10
更新的
配置

config = {
    "a": {
        "hello": 10,
        "goodbye": 2,
    }
}

为什么不干脆
config['a']['hello']=10