我正在编写一个函数来计算到道路上某些点的最短路径,而不是像乌鸦一样飞来飞去,但是我不断得到错误:
Traceback (most recent call last): File "P:\understandinggis\assessment2\Assessment2.py", line 177, in if shortestPath1(g, line) <= maxDist: File "P:\understandinggis\assessment2\Assessment2.py", line 14, in shortestPath1 azF,azB,distance = g.inv(line["coordinates"][l][0], line["coordinates"][l][1], lines["coordinates"][l+1][0], line["coordinates"][l+1][1]) TypeError: list indices must be integers, not str
这是它所指的代码行:
def shortestPath1 (g, line):
#initialise cumulativelength
cumulativeLength = 0
for l in range(len(line)-1):
azF,azB,distance = g.inv(line['coordinates'][l][0], line['coordinates'][l][1], lines['coordinates'][l+1][0], line['coordinates'][l+1][1])
cumulativeLength += distance
return cumulativeLength
目前没有回答
相关问题 更多 >
编程相关推荐