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

来源:互联网 发布:软件过程域哪些 编辑:程序博客网 时间:2024/06/06 02:29
import mathclass Point:    def __init__(self,x=0,y=0):        self.x=x        self.y=yclass Line(Point):    def getLen(self,p1,p2):        r=math.sqrt(((p1.x-p2.x)**2)+(p1.y-p2.y)**2)        return rp1=Point(1,1)p2=Point(4,5)l=Line()hh=l.getLen(p1,p2)print(hh)

原创粉丝点击