package main
import (
"fmt"
"strconv"
"strings"
)
func main() {
str := "张三"
fmt.Println(len(str))
str2 :=[]rune(str)
for i := 0;i < len(str2);i++{
fmt.Printf("%c\n",str2[i])
}
str3,_ := strconv.Atoi("123")
i := strconv.Itoa(123)
fmt.Printf("str3 = %T\ti = %T\n",str3,i)
var bytes = []byte(str)
fmt.Println(bytes)
var str4 = string(bytes)
fmt.Println(str4)
var str5 = strconv.FormatInt(123,16)
fmt.Println(str5)
var b = strings.Contains("123","3")
fmt.Println(b)
var s = strings.Count("sssbbbb","s")
fmt.Println(s)
var t = strings.EqualFold("abc","ABC")
fmt.Println(t)
var i2 int = strings.Index(str,"三")
fmt.Println(i2)
var i3 int = strings.LastIndex(str,"张")
fmt.Println(i3)
str = strings.Replace(str,"张","李",1)
fmt.Println(str)
var s1 []string = strings.Split("str,stb,stb",",")
fmt.Println(s1[0])
strings.ToLower("ABC")
strings.ToUpper("abc")
strings.TrimSpace(" 张三 ")
fmt.Println(strings.TrimSpace(" 张三 "))
strings.Trim("!张三!","!")
strings.TrimRight("!张三!","!")
strings.TrimLeft("!张三!","!")
strings.HasPrefix("张三","张")
strings.HasSuffix("张三","三")
fmt.Println(strings.HasPrefix("张三","张"))
fmt.Println(strings.HasSuffix("张三","三"))
}
转载请注明原文地址:https://blackberry.8miu.com/read-37359.html