package main import "fmt" func main() { var m = map[int]string{ 90: "优秀", 80: "良好", 60: "及格", //逗号不能省略,会报错 } //遍历map中的元素 for k, v := range m { fmt.Println(k, v) } for s := range m { fmt.Println(s) } //读取某个值 var score = m[90] fmt.Println(score) //map 中增加一项 m[70] = "中等" fmt.Println(m) //map 删除一项 delete(m, 60) fmt.Println(m) fmt.Println(m, len(m)) }