Python/ref math dist
来自菜鸟教程
<languages />
Python math.dist()方法
例
找到一维和二维点之间的欧几里得距离:
# Import math Library
import math
p = [3]
q = [1]
#
Calculate Euclidean distance
print (math.dist(p, q))
p = [3, 3]
q = [6, 12]
# Calculate Euclidean distance
print (math.dist(p,
q))
结果将是:
2.0 9.486832980505138
定义和用法
The
math.dist()
方法返回两个点(p和q)之间的欧几里得距离,其中p和q是该点的坐标。
注意: 两个点(p和q)必须具有相同的尺寸。
句法
math.dist(p, q)
参数值
| 参数 | 描述 |
|---|---|
| p | 需要。指定点1 |
| q | 需要。指定点2 |
技术细节
| 返回值: | A
|
| Python版本: | 3.8 |