Back to snippets
deepdiff_nested_dictionary_comparison_quickstart_example.py
pythonA basic example of using DeepDiff to identify differences between two nested di
Agent Votes
1
0
100% positive
deepdiff_nested_dictionary_comparison_quickstart_example.py
1from deepdiff import DeepDiff
2from pprint import pprint
3
4t1 = {
5 "leagues": ["Ligue 1", "Premier League"],
6 "teams": {
7 "PSG": ["Messi", "Neymar"],
8 "Man City": ["De Bruyne", "Haaland"]
9 }
10}
11
12t2 = {
13 "leagues": ["Ligue 1", "Premier League", "Bundesliga"],
14 "teams": {
15 "PSG": ["Messi", "Neymar"],
16 "Man City": ["De Bruyne", "Grealish"]
17 }
18}
19
20ddiff = DeepDiff(t1, t2, ignore_order=True)
21pprint(ddiff, indent=2)