Merge Keys by common value from the same dictionary
问题 Let's say that I have a dictionary that contains the following: myDict = {'A':[1,2], 'B': [4,5], 'C': [1,2]} I want to create a new dictionary, merged that merges keys by having similar values, so my merged would be: merged ={['A', 'C']:[1:2], 'B':[4,5]} I have tried using the method suggested in this thread, but cannot replicate what I need. Any suggestions? 回答1: What you have asked for is not possible. Your keys in the hypothetical dictionary use mutable lists. As mutable data can not be