go Title()
Title()方法语法
func Title(s string) string
go源码对TrimSuffix()方法的介绍:
Title returns a copy of the string s with all Unicode letters that begin words mapped to their Unicode title case.
BUG(rsc): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
即,golang的strings.Title(),接收一个字符串string类型的参数s,并将其中每个单词的首字母改写为标题格式,以一个新的字符串返回,并不修改原字符串。
strings.Title()方法实例代码
func main() {
var str string = strings.Title("hello, world")
fmt.Println(str)
}
运行go文件,得到输出:
Hello, World