我有以下代码,似乎我以错误的方式使用append
,因为我得到了:SyntaxError: can't assign to function call
i = 0
distance = []
distance.append(i) = measureDistance.Distance2BetweenPoints(p1, p2)
如何解决此问题?
感谢。
答案 0 :(得分:6)
如果您想在measureDistance.Distance2BetweenPoints(p1, p2)
位置插入i
的结果,您应该这样做 -
distance.insert(i, measureDistance.Distance2BetweenPoints(p1, p2))
如果你想把结果追加到最后,你应该做 -
distance.append(measureDistance.Distance2BetweenPoints(p1, p2))
答案 1 :(得分:2)
使用
i=0
distance = []
distance.insert(i,measureDistance.Distance2BetweenPoints(p1, p2)
或使用
distance = []
distance.append(measureDistance.Distance2BetweenPoints(p1, p2))