字符和符号(rune)
使用byte遍历字符串
package main
import (
"fmt"
)
func main() {
s := "str"
for i := 0; i < len(s); i++ {
c := s[i]
fmt.Printf("Byte at index %d is '%c' (0x%x)\n", i, c, c)
}
}Byte at index 0 is 's' (0x73)
Byte at index 1 is 't' (0x74)
Byte at index 2 is 'r' (0x72)使用rune遍历字符串
最后更新于