未来密钥中的字典我有3点字典:拆分从2个不同的其他字典
dict1 = {'Name1':'Andrew','Name2':'Kevin'....'NameN':'NameN'}- this would have maximum 20 names
dict2 = {'Travel':'Andrew','Footbal':'Kevin',...'Nhobby':'NameN'}- this would have as many names as there are in dict1
dict3 = {'Travel':'ID01','Footbal':'ID02','Travel':'ID03','Photo':'ID04','Footbal':'ID05','Photo':'ID06','Climbing':'ID07'....}
我想,这样的3TH一个结束这样的3个词典结合:
dict3 = {'Andrew':'ID01','Kevin':'ID02','Andrew':'ID03','Kevin':'ID04','Kevin':'ID05','Kevin':'ID06','Andrew':'ID07',....}. Basically the hobbies that are in the dict 2 will be kept while the remaining hobbies will be split among the total number of names with a +1 in the case of an uneven number of hobbies.
我已经尝试了从这里的合并函数Merge dictionaries retaining values for duplicate keys,但我有一个糟糕的时间在所有名称中平分dict3。
您的输出是不可能的。字典必须具有唯一的密钥。 – DeepSpace