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