dico = {"dico": {1:"bailler",2:"bailler",3:"percer",4:"calculer",5:"calculer",6:"trouer",7:"bailler",8:"découvrir",9:"bailler",10:"miser",11:"trouer",12:"changer"}}
我有一個這樣的字典的大詞典。我想把意識元素放在一起。因此,創造一種條件,這將說如果"dico"
的值等於把它們放在一個set()
:如何比較字典中的值來填充集合()
b=[set(1,2,7,9),set(3),set(4,5),set(6,11),set(8),set(10),set(12)]
我不知道,如果問題已經被問,但作爲一個新的pythonner我不擁有所有的鑰匙...... ^^
謝謝你的回答
你不能在一個集合中放置相等的項目(當然,你可以,但它不會影響集合)。集合正好相反。 – Hyperboreus
這看起來像這個問題類似的問題:[http://stackoverflow.com/questions/15751979/grouping-python-dictionary-keys-as-a-list-and-create-a-new-dictionary-with-這個](http://stackoverflow.com/questions/15751979/grouping-python-dictionary-keys-as-a-list-and-create-a-new-dictionary-with-this) – beercodebeer