[英]Why am I getting an invalid syntax
我正在尝试设置我的init,并且在尝试设置(x,y)时,在坐标的开放括号上收到无效的语法错误。
我觉得这将是一个明显的错误,但是我已经看了太久了,可能会用一些新鲜的眼睛...
def __init__(self, (x,y), size, color = (255,255,255)):
self.x = x
self.y = y
self.size = size
self.color = color
self.width = width
由于x和y是元组的元素(如果这就是您要创建的元素),则无需在参数中分配单个元素。
def __init__(self, coordinates, size, color = (255,255,255)):
self.x = coordinates[0]
self.y = coordinates[1]
self.size = size
self.color = color
self.width = width
您必须编写__init__(self, v , size, color = (255,255,255))
并将每个v
作为列表传递。
def __init__(self, v, size, color = (255,255,255)):
self.x = v[0] #first coordinate of v
self.y = v[1] #second coordinate of v
self.size = size
self.color = color
self.width = width
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.