Python已知xy坐標怎么批量計算兩點距離?
exp1:
x = [1,2,3,4,5,6,7,8,9]
res = []
for x1, x2 in zip(x[:-1], x[1:]):
res.append(math.sqrt(x1*x1+x2*x2))
-------
exp2:
x = [1,2,3,4,5,6,7,8,9]
res = []
res = map(lambda x1,x2: math.sqrt(x1*x1-x2*x2), x[:-1], x[1:])
----------------------