对字符串操作,可以先将string转换为[]rune或[]byte,完成后在转换为string
注:转换时,会重新分配内存,并复制字节数组
s := "abc"
bs := []byte(s)
bs[1]='B'
fmt.Println(string(bs))
u := "笨蛋"
us := []rune(u)
us[1] = '鸡'
fmt.Println(string(us))
for循环遍历字符串时,分为byte rune两种方式
for i:=0; i<len(s); i++ //byte
for _,r := range s //rune