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