python 字典提取出value相同的key
dic={‘a’:1,‘b’:2’,‘c’:1}
想要提取出list=[[‘a’,‘c’],[‘b’]]
:
new_dict = {}
for k, v in some_dict.items():
new_dict.setdefault(v, []).append(k)
from: https://wenwen.sogou.com/z/q908560056.htm
python 字典提取出value相同的key
dic={‘a’:1,‘b’:2’,‘c’:1}
想要提取出list=[[‘a’,‘c’],[‘b’]]
:
new_dict = {}
for k, v in some_dict.items():
new_dict.setdefault(v, []).append(k)
from: https://wenwen.sogou.com/z/q908560056.htm