是否有理由将列表分配给另一个列表并在一个列表中更改项目反映两者中的更改,但更改一个列表的整个列表并不反映两者中的更改?
a=5
b=a
a=3
print b #this prints 5
spy = [0,0,7]
agent = spy
spy[2]=8
print agent #this prints [0,0,8]
spy = [0,0,7]
agent = spy
spy = "hello"
print agent #this prints [0,0,7]
Run Code Online (Sandbox Code Playgroud)