23
さまざまな深さのネストされた辞書の値を更新する
レベルAを上書きせずにdict update1の内容でdict dictionary1を更新する方法を探しています dictionary1={'level1':{'level2':{'levelA':0,'levelB':1}}} update={'level1':{'level2':{'levelB':10}}} dictionary1.update(update) print dictionary1 {'level1': {'level2': {'levelB': 10}}} updateはlevel2の値を削除することを知っています。これは、最も低いキーlevel1を更新しているためです。 dictionary1とupdateは任意の長さにできるので、これにどのように取り組むことができますか?
162
python