各位大大好
请问class内是否可以各个物件使用各自的list呢?
我发现 two.thelist 会出现'10',但是实际append在one
请问原因是什么呢?
要如何各自使用各自的list呢?(one & two 拥有不同的thelist)
请大大指点迷津! 感激不尽~
e.g.
class class1():
theint = -1
thelist=[]
def __init__(self, A, B):
print(A)
self.theint = A
self.thelist.append(B)
one = class1(123)
two = class1(456)
one.thelist.append(10)
one.thelist
>> Out: [456, 789, 10]
two.thelist
>> Out: [456, 789, 10]