使用的书本是python2.x ,在python3.x 中无法导入point类,只能加载下面point类,可以运行。
参考博客:https://blog.youkuaiyun.com/huoxingrenhdh/article/details/71708936
import math
class Point(object):
def __init__(self,xParam = 0.0,yParam = 0.0):
self.x = xParam
self.y = yParam
def __str__(self):
return "(%.2f, %.2f)"% (self.x ,self.y)
def distance (self,pt):
xDiff = self.x - pt.x
yDiff = self.y - pt.y
return math.sqrt(xDiff ** 2 + yDiff ** 2)
def sum(self,pt):
newPt = Point()
xNew = self.x