所以,我想在這裏實現的是採取2個字典,採取在同一個「點」的兩個字典的值,並能夠應用任何功能。下面是一些僞代碼的例子:比較兩個不同的字典與隨機函數
If f(a, b) returns a + b
d1 = {1:30, 2:20, 3:30, 5:80}
d2 = {1:40, 2:50, 3:60, 4:70, 6:90}
then function(d1, d2) returns ({1: 70, 2: 70, 3: 90}, {4: 70, 5: 80, 6: 90})
If f(a, b) returns a > b
d1 = {1:30, 2:20, 3:30}
d2 = {1:40, 2:50, 3:60}
then function(d1, d2) returns ({1: False, 2: False, 3: False}, {})
究竟什麼是你的問題只返回與鍵的字典鍵值?請查看[FAQ](http://stackoverflow.com/tour)和[如何提問](http://stackoverflow.com/help/how-to-ask)。 –
看看這篇文章http://stackoverflow.com/questions/10461531/merge-and-sum-of-two-dictionaries – AlvaroP
我不知道如何設置一個函數,比較後將返回值2個字典。你將不得不使用for循環並在使用返回函數之後?對於不問這個問題,我表示歉意,我對此很陌生。 – Alex