读书笔记:
我的代码:
# -*- coding: gbk -*-
import math
class Point():
def __init__(self,x,y):
self.x = x
self.y = y
class Line():
def __init__(self,p1,p2):
self.p1 = p1
self.p2 = p2
def getLength(self):
return math.sqrt((self.p1.x-self.p2.x)**2+\
(self.p1.y-self.p2.y)**2)
p1 = Point(1,1)
p2 = Point(7,9)
line = Line(p1,p2)
print("线段的长度是:%.2f"%line.getLength())