golang中字符串操做函數strings.Comparehtml
package main import ( "fmt" "strings" ) //golang字符串操做 func main(){ s := "Hello world hello world" str := "Hello" //var s = []string{"11","22","33"} //比較字符串,區分大小寫,比」==」速度快。相等爲0,不相等爲-1。 ret := strings.Compare(s,str) fmt.Println(ret) // 1 }