未來密鑰中的字典我有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