01 2022 档案
摘要:
type后面接的都是类型 自定义类型和别名 package main import "fmt" type myint int //自定义类型,编译完还保留 type tmpint = int //类型别名,只在代码编写时有效 func main() { var x myint = 10 fmt.Pr
阅读全文

摘要:
map的遍历和判断键是否存在 package main import ( "fmt" "strings" ) func main() { // 统计how do you do 单词的出现次数 s1 := "how do you do" sl1 := strings.Split(s1, " ") m1
阅读全文

摘要:
数组长度是数组类型的一部分 数组的定义 //声明 var a1 [3]int fmt.Print(a1) //赋值,注意要加上长度和类型 a1 = [3]int{1, 2, 3} //函数中的方法1 a2 := [3]int{1, 2, 3} //函数中的方法2 a3 := [...]int{1,
阅读全文

摘要:
统计hello沙河小王子的中文字符个数 package main import ( "fmt" "unicode" ) func main() { s := "hello沙河小王子" var cnt int for _, v := range s { // if unicode.Is(unicode
阅读全文
