Go语言 编写代码统计出字符串中汉字的数量

编写代码统计出字符串"hello沙河小王子"中汉字的数量。

a := 0
	s1 := "hello沙河小王子"
	for _, i := range s1 {
    
    
		if i > 'z' {
    
    
			a ++
		}
	}
	fmt.Println(a)

猜你喜欢

转载自blog.csdn.net/weixin_45765795/article/details/112464188