How to check if the contents of the dictionary are the same in Python by hash value
In the dictionary type, the order of the keys is not fixed, so you can't just convert it to a character string and ask for md5.
Zubari this
import hashlib
import json
data = ['only', 'lists', [1,2,3], 'dictionaries', {'a':0,'b':1}, 'numbers', 47, 'strings']
data_md5 = hashlib.md5(json.dumps(data, sort_keys=True)).hexdigest()
reference https://stackoverflow.com/questions/5417949/computing-an-md5-hash-of-a-data-structure
Recommended Posts