這段代碼可以嗎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
提交
取消