小白教程
所有教程
关于
Search
172.69.59.47
172.69.59.47
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Ref math dist”的源代码
本页内容
上一节:
Ref_math_degrees
下一节:
Ref_math_erf
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:math.dist(p, q)}}[[Category:python math|19]] = Python math.dist() 方法 = [[python math|Python math 模块]] Python '''math.dist(p, q)''' 方法返回 p 与 q 两点之间的欧几里得距离,以一个坐标序列(或可迭代对象)的形式给出。 两个点必须具有相同的维度。 传入的参数必须是正整数。 Python 版本:3.8 === 语法 === math.dist() 方法语法如下: <sample title="" desc="" lang="python" hererun="1"> math.dist(p, q) </sample> '''参数说明:''' * '''p''' -- 必需,指定第一个点。 * '''q''' -- 必需,指定第二个点。 === 返回值 === 返回一个浮点值,表示 p 和 q 之间的欧几里得距离。 == 以下实例返回两个点的欧几里得距离: <sample title="" desc="" lang="python" hererun="1"> # 导入 math 包 import math p = [3] q = [1] # 计算欧几里得距离 print (math.dist(p, q)) p = [3, 3] q = [6, 12] # 计算欧几里得距离 print (math.dist(p, q)) </sample> 输出结果: <sample title="" desc="" lang="python" hererun="1"> 2.0 9.486832980505138 </sample> [[python math|Python math 模块]]
返回至“
Ref math dist
”。
上一节:
Ref_math_degrees
下一节:
Ref_math_erf