📜  欧几里得距离 python 3 个变量 - Python 代码示例

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

代码示例1
# Python code to find Euclidean distance 
# using sum() and square() 
  
import numpy as np 
  
# intializing points in 
# numpy arrays 
point1 = np.array((1, 2, 3)) 
point2 = np.array((1, 1, 1)) 
  
# finding sum of squares 
sum_sq = np.sum(np.square(point1 - point2)) 
  
# Doing squareroot and 
# printing Euclidean distance 
print(np.sqrt(sum_sq))