📜  python 两点之间的最短距离 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:24.156000             🧑  作者: Mango

代码示例1
points = [(1,5), (5,8), (8,1), (9,5)]

def euclideanDistance(coordinate1, coordinate2):
    return pow(pow(coordinate1[0] - coordinate2[0], 2) + pow(coordinate1[1] - coordinate2[1], 2), .5)

distances = []
for i in range(len(points)-1):
    for j in range(i+1, len(points)):
        distances += [euclideanDistance(points[i],points[j])]
print min(distances)