Created
March 24, 2021 09:30
-
-
Save bast/85a5c2eda5501fe915faaa84846abe29 to your computer and use it in GitHub Desktop.
Comparing dictionaries in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/seperman/deepdiff | |
from deepdiff import DeepDiff | |
d1 = {"something": 1, "another": 2, "yet another": 3} | |
d2 = {"something": 2, "another": 2, "yet another": 3} | |
difference = DeepDiff(d1, d2, ignore_order=True) | |
print(difference) | |
d1 = {"something": 1, "another": 2, "yet another": 3} | |
d2 = {"something": 1, "yet another": 3, "another": 2} | |
difference = DeepDiff(d1, d2, ignore_order=True) | |
print(difference) | |
d1 = {"something": 1, "another": 2, "yet another": 3, 'subdict': {'a': 2, 'b': 3}} | |
d2 = {"something": 1, "another": 2, "yet another": 3, 'subdict': {'a': 3, 'b': 3}} | |
difference = DeepDiff(d1, d2, ignore_order=True) | |
print(difference) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment