Now there are two dicts. This dict has two levels (it would be better if the number of levels can be customized or unlimited) and I want to merge them
case1:
Input: a: {1:{"171": True}} b:{1:{"172": False}}
Output: {1:{"171": True , "172": False}}
case2:
Input: a: {1:{"171": True}} b:{1:{"171": False}}
Output: {1:{"171": False }}
The dict.update method I use in python can only be used in one layer. Is there any good implementation method?
I just wrote a merge that handles multi-layer dictionaries
Only tested python3.6.1, you only need to call deep_merge
The writing is more functional, don’t blame me
For case2 it is relatively simple:
For case1 you can do this:
You can encapsulate the above operations into functions.