quarrying 4 жил өмнө
parent
commit
95fdedd919
1 өөрчлөгдсөн 7 нэмэгдсэн , 1 устгасан
  1. 7 1
      khandy/utils_dict.py

+ 7 - 1
khandy/utils_dict.py

@@ -160,5 +160,11 @@ def merge_multidict(*mdicts):
     return merged_multidict
     
     
+def invert_multidict(multidict_obj):
+    inverted_dict = {}
+    for key, value in multidict_obj.items():
+        for item in value:
+            inverted_dict.setdefault(item, []).append(key)
+    return inverted_dict
     
-    
+