TypeError: setcoords() missing 1 required positional argument: 'coords1'
TypeError: setcoords() missing 1 required positional argument: 'coords1'
full code with error message
我正在尝试 class 来绘制三角形,但显然在第 29 行中有一个我无法解决的问题。我在这里阅读了其他一些问题,但它们主要是关于 'self' 这不是我的错误
def setcoords(self,coords1):
self.coords=coords1
triangle.setcoords(((100,100),(150,200),(200,100)))
print (triangle.givecoords())
triangle.setcolor((0,255,0))
triangle.setvisible(True)
triangle.draw()
您必须创建一个 Instance Objects:
my_triangle = triangle()
my_triangle.setcoords(((100,100),(150,200),(200,100)))
Class Names should normally use the CapWords convention and have a constructor (__init__
):
class Triangle:
def __init__(self, coords1):
self.coords = coords1
# [...]
my_triangle = Triangle([(100,100),(150,200),(200,100)])
full code with error message
我正在尝试 class 来绘制三角形,但显然在第 29 行中有一个我无法解决的问题。我在这里阅读了其他一些问题,但它们主要是关于 'self' 这不是我的错误
def setcoords(self,coords1):
self.coords=coords1
triangle.setcoords(((100,100),(150,200),(200,100)))
print (triangle.givecoords())
triangle.setcolor((0,255,0))
triangle.setvisible(True)
triangle.draw()
您必须创建一个 Instance Objects:
my_triangle = triangle()
my_triangle.setcoords(((100,100),(150,200),(200,100)))
Class Names should normally use the CapWords convention and have a constructor (__init__
):
class Triangle:
def __init__(self, coords1):
self.coords = coords1
# [...]
my_triangle = Triangle([(100,100),(150,200),(200,100)])