我对 OOP 和 Python 很陌生。我所知道的几乎所有内容都是自学的,因此如果您能提供一些链接供我阅读,我将不胜感激,因为我不知道为了澄清我的疑问而应该寻求的确切术语。
到目前为止,这是我的代码:
class Point(object):
x = 2
y = 3
def __init__(self, x, y):
self.x_a = x
self.y_b = y
class RectPoint(Point):
def __init__(self, x, y):
self.x_1 = x
self.y_1 = y
self.dist = (x*x + y*y)**0.5
class CircPoint(Point):
pass
a = Point(3,4)
b = CircPoint(3,4)
c = RectPoint(3,4)
print a.x # 2
print a.y # 3
print a.x_a # 3
print a.y_b # 4
print b.x # 2
print b.y # 3
print b.x_a # …
Run Code Online (Sandbox Code Playgroud)