Golang中的遍历map可以使用for range循环进行map遍历,得到key和value值。 遍历key以及遍历key+value12345678910111213141516171819package mainimport "fmt"func forr_key_map() { var m1 = make(map[string]string) m1["name"] = "weiyunfeng" m1["age"] = "23" m1["email"] = "[email protected]" for k := range m1 { fmt.Printf("key: %v\n", k) } for k1, v := range m1 { fmt.Printf("%v: %v\n", k1, v) }}func main() { forr_key_map()} 运行结果 123456key: namekey: agekey: emailage: 23email: 905577137@qq.comname: weiyunfeng