标签: python python-3.x python-2.7 nested-lists
我正在尝试以下代码:
b = [[None]*3]*3 b[0][2] = 1 print(b)
并获得如下输出: [[None, None, 1], [None, None, 1], [None, None, 1]]
[[None, None, 1], [None, None, 1], [None, None, 1]]
但是我期望的是: [[None, None, 1], [None, None, None], [None, None, None]]
[[None, None, 1], [None, None, None], [None, None, None]]
我在这里想念什么?