package main
import "fmt"
func main() {
str := "0cc175b9c0f1b6a831c399e269772661";
fmt.Println(str[0:2])
fmt.Println(str[2:4])
fmt.Println(str[4:6])
fmt.Println(str[2:])
fmt.Println(str[len(str)-2:len(str)])
//中文
s := "a我cd"
s = string([]rune(s)[:3])
fmt.Println(s) //得到 "a我c"
}
结果:
0c
c1
75
c175b9c0f1b6a831c399e269772661
61
a我c