摘要: package main import ( "fmt" "strings" ) func main(){ //返回字符在指定字符串中最后一次出现的位置 last_index := strings.LastIndex("Hello World", "l") fmt.Printf("last_index=%v\n", last_index) /... 阅读全文
posted @ 2018-08-20 23:08 温柔的风 阅读(727) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "strings" "strconv" ) func main(){ //返回字符串的(字节)长度,相当于PHP的strlen str := "hello世界" //11 ,golang的编码统一为utf-8,字母和数字分别占一个字节,汉子占用3个字节 // str := "hello"... 阅读全文
posted @ 2018-08-20 10:08 温柔的风 阅读(229) 评论(0) 推荐(0) 编辑