我在互联网上读到的关于整数和字符串的内容是它们本质上是不可变的。但是下面的代码表明,在改变这些类型的值之后,它们仍然指向同一个地址。这与 python 中类型的本质背后的想法相矛盾。谁能解释一下这个?提前致谢。
package main
import (
"fmt"
)
func main() {
num := 2
fmt.Println(&num)
num = 3
fmt.Println(&num) // address value of the num does not change
str := "2"
fmt.Println(&str)
str = "34"
fmt.Println(&str) // address value of the str does not change
}```
红颜莎娜
交互式爱情