The variable x
contains a pointer to the array.
When writing y = x
, you only assigned the pointer to the array to y
. Because both variables point to the same array, any change made through x
or y
will be applied on the same data.
You can copy the array to have a different one: y = x.copy()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…