尝试将新元素添加到我的cells类对象列表时,我注意到所有列表值都是添加项目的最后一个值。我使用 append 添加新项目。我怎样才能得到正确的答案?
class cells:
x=0
from cells import cells
a=[]
a.append(hucre)
a[0].x=10
a.append(hucre)
a[1].x=20
a.append(hucre)
a[2].x=30
print(a[0].x) #30 where must give me 10
print(a[1].x) #30 where must give me 20
print(a[2].x) #30 where must give me 10
猛跑小猪
相关分类