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.
这可以减少到单行(分配后a)吗?
a
a = [1,2,3] b = a[:] b.append(4)
以下可能是最简单的:
b = a + [4]
在这里,您不需要,a[:]因为我们不再复制引用(+无论如何都会创建并返回一个新列表)。
a[:]
+