飞克网

标题: 字符串操作函数介绍 [打印本页]

作者: admin    时间: 2020-1-26 14:55
标题: 字符串操作函数介绍
strings.Contains("hellogo","go") //包含返回true,不包含返回false


strings.Join(s,",")//字符串组合


strings.Index("abcd","b")//字符索引,如果不存在则返回-1


strings.Repeat("go",3)//字符串重复输出3次


strings.Split("abc ded afe"," ")//字符串拆分成数组


strings.Trim(" abc "," ")//去掉两头的空白


strings.Fields("adf aef daef")//去掉空格组合成数组


strings.Replace("abc cc afc","c","y",-1)//将字符串c,替换成y,-1表示全部






欢迎光临 飞克网 (http://feikechina.com/) Powered by Discuz! X3.2