我想将temp列表的值添加到主列表中。我尝试将一些值添加到temp列表中,然后将temp列表附加到主列表中,如下所示,但主列表总是显示最新的值。
>>> temp =[]
>>> temp.append(123)
>>> temp.append(10)
>>> temp.append(18)
>>> mutR =[]
>>> mutR.append(temp)
>>> print mutR
[[123, 10, 18]]
>>> temp[:]=[]
>>> temp.append(3)
>>> temp.append(4)
>>> temp.append(5)
>>> mutR.append(temp)
>>> print mutR
[[3, 4, 5], [3, 4, 5]]
我的期望是:
>>> print mutR
[[123, 10, 18], [3, 4, 5]]
但它是[[3, 4, 5], [3, 4, 5]]
。