Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这可能是非常基本的,但我无法在 python 3 中导航嵌套列表。
list1 = [[0]*3]*3 list1[0][1] = 1 print(list1)
产生输出
[[0, 1, 0], [0, 1, 0], [0, 1, 0]]
当我期望输出是
[[0, 1, 0], [0, 0, 0], [0, 0, 0]]
为什么会这样?