2024-04-27 02:34:03 发布
网友
我试着从两条直线的交点处找到坐标,在相交定义处,我有一个错误:
unsupported operand type(s) for +: 'int' and 'classobj'
我能做些什么来修复它?在
改变
Line2=IntersectionPoint(3,-1 -1, Line1)
到
您传入了4个参数,但缺少一个逗号
您正在将一个类对象传递给IntersectionPoint():
IntersectionPoint()
Line1是一个类。这是函数的第三个参数,因为这两个-1参数之间没有逗号。因此,您将3分配给a2,-2分配给b2,并将{}分配给c2。在
Line1
-1
3
a2
-2
b2
c2
然后,在intersect方法中,将该类对象添加到一个整数中:
intersect
其中self.c2是您的Line1类。在
self.c2
你想要:
Line2 = IntersectionPoint(3, -1, -1)
相反。在
下一个错误是:
return 'True. The intersection point is: I' (xcord,ycord)
因为这就像是把字符串当作函数。您可能缺少字符串格式操作,或者缺少逗号:
return 'True. The intersection point is: (%d, %d)' % (xcord,ycord)
或者
return 'True. The intersection point is: I', (xcord,ycord)
改变
到
^{pr2}$您传入了4个参数,但缺少一个逗号
您正在将一个类对象传递给
IntersectionPoint()
:Line1
是一个类。这是函数的第三个参数,因为这两个-1
参数之间没有逗号。因此,您将3
分配给a2
,-2
分配给b2
,并将{c2
。在然后,在
^{pr2}$intersect
方法中,将该类对象添加到一个整数中:其中
self.c2
是您的Line1
类。在你想要:
相反。在
下一个错误是:
因为这就像是把字符串当作函数。您可能缺少字符串格式操作,或者缺少逗号:
或者
相关问题 更多 >
编程相关推荐