// test14 project main.go package main import ( //"fmt" "io/IoUtil" "log" "os" "strings" "unicode" ) func main() { file,err := os.Open("./aa.txt") if err != nil { log.Fatal(err) } defer file.Close() data,_ := IoUtil.ReadAll(file) words := strings.FieldsFunc(string(data),func(ch rune) bool { return !unicode.IsLetter(ch) //任何不是字母的字符都是分隔符 }) for _,word := range words { log.Println(word) } }原文链接:https://www.f2er.com/go/188060.html