写点类,再写直线类,算两点间的距离

import math
class Point:
    def __init__(self,x=0,y=0):
        self.x=x
        self.y=y


class Line(Point):
    def getLen(self,p1,p2):
        r=math.sqrt(((p1.x-p2.x)**2)+(p1.y-p2.y)**2)
        return r



p1=Point(1,1)
p2=Point(4,5)
l=Line()
hh=l.getLen(p1,p2)
print(hh)

posted on 2017-08-05 04:18  我是蒟蒻  阅读(171)  评论(0编辑  收藏  举报

导航