我有一个在程序运行时添加项目的列表,并且我创建了该列表的副本,因此我可以更改/修改/检查副本而不更改原始副本。
这是我到目前为止所得到的:
import copy
originallist.append(stuff)
combined=''.join(originallist)
copyoriginal=copy.deepcopy(originallist)
##this didnt work as copyoriginal stayed empty [] while originallist would change.
#i also tried
copyoriginal=list(originallist)
#AND
copyoriginal=originallist[:]
#and with both cases copyoriginal remained at [] while originallist would change!!
为什么不改变?