【发布时间】:2014-01-28 20:49:14
【问题描述】:
我正在尝试以单行有效的方式制作列表列表,但我想不出任何方法来避免引用。这是我迄今为止尝试过的,显然没有成功:
>>> test=[[None]*3][:]*3
>>> test
[[None, None, None], [None, None, None], [None, None, None]]
>>> test[0][0]=0
>>> test
[[0, None, None], [0, None, None], [0, None, None]]
>>>
这不是我想要发生的。我想要的是 0 成为第一个列表的第一项。我该怎么做?
【问题讨论】: