while stack.isEmpty() != 1:
fin = stack.pop()
print fin - output is (1,1)
k = final.get(fin)
return k
def directionToVector(direction, speed = 1.0):
dx, dy = Actions._directions[direction]
return (dx * speed, dy * speed)
directionToVector = staticmethod(directionToVector)
,但是当我这样做的回报,它给了我一个错误,最后是我的钥匙的名单由和值错误执行Python代码 - 字典问题
的错误是目录:
File "line 212, in directionToVector
dx, dy = Actions._directions[direction]
KeyError: 'W'
我想'而不是stack.isEmpty():'看起来好一点 – SiggyF 2010-07-18 09:01:12
或'而堆栈:'假设它是一个列表。 – 2010-07-18 09:04:15
ys ... bt它不会使n]在输出中有任何不同 – Shilpa 2010-07-18 09:05:23