马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import math
class Point1:
def __init__(self, x1, y1):
self.x1 = x1
self.y1 = y1
p = Point1(2, 2)
class Point2:
def __init__(self, x2, y2):
self.x2 = x2
self.y2 = y2
p = Point2(4, 4)
class Line(Point1, Point2):
def __init__(self):
super().__init__()
def get_len(self):
square = (self.x2 - self.x1)*(self.x2 - self.x1) + (self.y2 - self.y1)*(self.y2 - self.y1)
line = math.sqrt(square)
print(self.line)
l = Line()
l.get_len()
#报错内容Traceback (most recent call last):
File "E:\my option\python\038题目.py", line 192, in <module>
l = Line()
File "E:\my option\python\038题目.py", line 185, in __init__
super().__init__()
TypeError: __init__() missing 2 required positional arguments: 'x1' and 'y1'
#我已经用super()函数加载了Point1,Point2的属性,怎么出现了类型错误啊?传入的y1和x1都是int类型呀,怎么是TypeError了呀?
|