源码如下:
shadow = [{
"name": "admin",
"password": "admin",
"age": "18",
},
{
"name": "xys",
"password": "123132",
"age": "18",
}
]
arr1 = list(filter(lambda x:x["name"] == "xys", shadow))
arr1[0].update({
"name": "yourself"
})
print(arr1) # 输出 [{'name': 'yourself', 'password': '123132', 'age': '18'}]
print(shadow[1]) #输出 {'name': 'yourself', 'password': '123132', 'age': '18'}
问:为什么在arr上修改值会影响源数值