类中的Python调用函数我有这样的代码,它计算两个坐标之间的距离。这两个函数都在同一个类中。但是,如何调用该函数?distToPoint在函数中isNear?class Coordinates:
def distToPoint(self, p):
"""
Use pythagoras to find distance
(a^2 = b^2 + c^2)
"""
...
def isNear(self, p):
distToPoint(self, p)
...
3 回答
ibeautiful
TA贡献1993条经验 获得超6个赞
self.
def isNear(self, p): self.distToPoint(p) ...
呼如林
TA贡献1798条经验 获得超3个赞
distToPointclassname.distToPoint(self, p)self.distToPoint(p).
添加回答
举报
0/150
提交
取消
