【发布时间】:2010-07-18 08:55:50
【问题描述】:
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)
但是当我返回时,它给了我一个错误,最终是我用键和值列表创建的目录
错误是:
File "line 212, in directionToVector
dx, dy = Actions._directions[direction]
KeyError: 'W'
【问题讨论】:
-
我觉得
while not stack.isEmpty():看起来更好一点 -
或者
while stack:,假设它是一个列表。 -
ys...bt 它不会使 n] 输出有任何差异
-
你可以在 之前
while stack.isEmpty() != 1:发布更多代码吗?你在哪里打电话给directionToVector? -
我没有在我的代码中的任何地方调用 diretionToVector...有一个文件已经定义了这个函数。有很多在其他文件中运行的函数就像...非法方向,总成本......等等......
标签: python dictionary