哈希字典? - Hashing a dictionary?

問題:

For caching purposes I need to generate a cache key from GET arguments which are present in a dict.出於緩存目的,我需要從 dict 中存在的 GET 參數生成緩存鍵。

Currently I'm using sha1(repr(sorted(my_dict.items()))) ( sha1() is a convenience method that uses hashlib internally) but I'm curious if there's a better way.目前我正在使用sha1(repr(sorted(my_dict.items())))sha1()是一種在內部使用hashlib的便捷方法)但我很好奇是否有更好的方法。


解決方案:

參考一: https://en.stackoom.com/question/OgiI
參考二: https://stackoom.com/question/OgiI
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章