当前第2页 返回上一页
按Unicode字符遍历字符串
同样的内容:
1 2 3 4 5 6 7 8 9 10 | package main
import "fmt"
func main() {
theme := "hello php中文网"
for _, s := range theme {
fmt.Printf( "Unicode: %c %d\n" , s, s)
}
}
|
程序输出如下:
1 2 3 4 5 6 7 8 9 10 11 12 | Unicode: h 104
Unicode: e 101
Unicode: l 108
Unicode: l 108
Unicode: o 111
Unicode: 32
Unicode: p 112
Unicode: h 104
Unicode: p 112
Unicode: 中 20013
Unicode: 文 25991
Unicode: 网 32593
|
可以看到,这次汉字可以正常输出了。
总结
推荐学习:Golang教程
以上就是go语言中字符串怎么逐个取出的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
Go语言条件语句
Go语言中数组和切片的区别是什么?
Go语言是什么开源协议
Go语言slice怎么删除元素
Go语言值传递介绍
Go语言如何求字符串长度
Go语言中函数与方法有什么区别
Go语言属于什么语言
Go语言怎么将数组转为字符串
Go语言如何把int转为字符串
更多相关阅读请进入《Go语言》频道 >>
老貘
一个与时俱进的Go编程知识库。
转载请注明出处:木庄网络博客 » go语言中字符串怎么逐个取出