这段代码可以吗class Point: def __init__(self,x,y): self.x=x self.y=y def __str__(self): return "Point({},{})".format(self.x,self.y)p=Point(3,5)print(p)修改为以下代码?class Point: def __init__(p,x,y): p.x=x p.y=y def __str__(p): return "Point({},{})".format(p.x, p.y)p=Point(3,5)print(p)在这种情况下似乎可行。但它是如此天真。我想知道在某些情况下使用“self”以外的东西会导致一些问题。
添加回答
举报
0/150
提交
取消