//对字符串中汉字数量进行统计
//unicode.Is()
package mainimport ( "fmt" "unicode")//Han示意汉字,其它语言表达可在字符集中查问func main() { a := "すごい,明天你pass了English考试" count := 0 for _, v := range a { if unicode.Is(unicode.Han, v) { count++ } } fmt.Println(count)}
运行后果:6