#拒绝回答一系列代码细节,自行百度学习对应函数
import re
import math
print("Input four numbers seperated by scape, enter `#` for ending input")
myinputs = []
t = input("four numbers:")
while t != "#":
tmp = re.split("\s+",t)
tmp = tuple([float(i) for i in tmp])
if len(tmp) != 4:
print("Wrong input! input another one")
else:
print("Other pair of points or `#` for ending?")
myinputs.append(tmp)
t = input("four numbers:")
print("Input pairs of points:")
for i in myinputs:
print(i)
print("The distances:")
for i in myinputs:
d = math.sqrt((i[0]-i[2])**2 + (i[1]-i[3])**2)
print("%.2f" % d)
'''
例子如下
Input four numbers seperated by scape, enter `#` for ending input
four numbers:1 1 2 2
Other pair of points or `#` for ending?
four numbers:2 3 4 5
Other pair of points or `#` for ending?
four numbers:#
Input pairs of points:
(1.0, 1.0, 2.0, 2.0)
(2.0, 3.0, 4.0, 5.0)
The distances:
1.41
2.83
'''
追问谢谢