请帮助我了解Example#1-B的结果:
Example#1-A:
ref=[3,5,9]
c=ref[:]
c[1]=0
# c equals to [3,0,9], and ref equals to [3, 5, 9]
Example#1-B:
ref=[[1,2],[3,4]]
c=ref[:]
c[0][1]=0
# c equals to [[1, 0], [3, 4]], and ref equals to [[1, 0], [3, 4]]
Example#2-A:
ref=[3,5,9]
c=copy.deepcopy(ref)
c[1]=0
# c equals to [3, 0, 9], and ref equals to [3, 5, 9]
Example#2-B:
ref=[[1,2],[3,4]]
c=copy.deepcopy(ref)
c[0][1]=0
# c equals to [[1,0],[3,4]], and ref equals to [[1,2],[3,4]]
答案 0 :(得分:0)
列表是可变的。
示例1-B中的行\d*(?:(?:012|123|234|345|456|567|678|789)|(?:987|876|765|654|543|432|321|210))\d*
复制新列表c=ref[:]
中ref
的子列表的引用
因此,您可以从c
和ref