当前第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语言中while是关键字吗
Go语言适合开发什么
Go语言指针作为函数参数
Go语言依赖管理介绍
Go语言怎么将int转为字符串类型
怎样下载安装Go语言
用Go语言怎么实现字符串比较
Go语言有什么特点?
Go语言相关工具怎么安装
更多相关阅读请进入《Go语言》频道 >>
老貘
一个与时俱进的Go编程知识库。
转载请注明出处:木庄网络博客 » go语言中字符串怎么逐个取出