#example code
a=b=c=[0,1,2] # a,b,c assign the same address of list
b=b+[3,4,5] # b will create new list to store the new list
c+=[97,98,99] # c is in place change
print(a,b,c)
print (a is b, a is c ) # use 'is' to check is the same object or not
output
[0, 1, 2, 97, 98, 99] [0, 1, 2, 3, 4, 5] [0, 1, 2, 97, 98, 99]
False True
[Finished in 0.0s]
沒有留言:
張貼留言