📜  两个数组的距离 euc 代码示例

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

代码示例2
# I hope to be of help and to have understood the request
from math import sqrt # import square root from the math module
# the x and y coordinates are the points on the Cartesian plane
pointA = (x, y) # first point
pointB = (x, y) # second point
distance = calc_distance(pointA, pointB) # here your beautiful result
def calc_distance(p1, p2): # simple function, I hope you are more comfortable
  return sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) # Pythagorean theorem