go语言 rune切片

时间:2022-08-14 11:56:52

go语言 rune切片 示例

package main

import (
"fmt"
)
//http://www.cnblogs.com/osfipin/
func main() {
var s = "go程序"
var r = []rune(s)
fmt.Printf("%c ", s[])
fmt.Printf("%c\n", r[]) fmt.Printf("%c ", s[])
fmt.Printf("%c\n", r[])
}

运行结果:

o o
¨ 序

针对汉字 utf8字符