新手请看本篇 - Python - 题解 | 绕距
绕距
https://www.nowcoder.com/practice/7a245fc6284f4139b4fb21de58e68483
import math # 公式中留参参数 x1,y1 = map(int,input().split()) x2,y2 = map(int,input().split()) # 求公差 gx = x1 - x2 gy = y1 - y2 # 根据公式带入 dm = abs(gx) + abs(gy) de = math.sqrt(gx * gx + gy * gy) #math.sqrt是根号 # abs是绝对值 sj = abs(dm-de) print(f"{sj:.6f}") #这里限制小数点6位 # 本代码适合新手查看学习 你需要看的是公式里的参数 而不是题目整体