s = problem.getSuccessors(currNode)
print s
child = dict((t[0], t[1:]) for t in s)
print child
output of s = [((5, 4), 'South', 1), ((4, 5), 'West', 1)]
output of child = {(4, 5): ('West', 1), (5, 4): ('South', 1)}
爲什麼訂單已更改? 5,4應該在第一個位置和(4,5)在小孩字典的第二個位置。python中的字典
而我該如何爲密鑰提供更多的價值?
這裏我的關鍵是(5,4),它的值是南和1.現在我想要它的父節點也作爲它的值,所以當我使用密鑰[1] - 它不能給我南, 1和父節點
因爲「s」只包含2個東西,南和1,所以它只產生2個值。我還需要1個。命令是什麼?
[Python項目中排序的項目]的可能重複(http://stackoverflow.com/questions/3127945/items-ordering-in-python-dictionary) – fortran 2011-12-09 12:49:22