go 学习

时间:2021-06-21 20:34:27   收藏:0   阅读:0

go语言 用go统计字符串中汉字的数量

import (
	"fmt" 
)
func main() {
  a := 0
	s1 := "hello沙河小王子"
	for _, i := range s1 {
		if i > ‘z‘ {
			a ++
		}
	}
	fmt.Println(a)
}//终端中运行 代码自动整理 go fmt main.go  
评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!