1
对于args= ['', '0', 'P1', 'with', '10']
和students=[['1', '2', '3', 6]]
它打印:Python的list.append变化的元素之后
[[['1', '2', '3', 6]]]
[[['10', '2', '3', 6]]]
预期产量为:
[[['1', '2', '3', 6]]]
[[['1', '2', '3', 6]]]
但它在某种程度上改变了backup_list
任何快速解决方案?
backup_list.append(students[:])
print(backup_list)
students[int(args[1])][0] = args[4]
print(backup_list)
非常感谢它,但是您能否更深入地解释它为什么会这样做以及它为什么不具有浅拷贝:3? – Skillwalker