对比python, java都有对应的字典类型及哈希类型。
package main import ( "fmt" ) //main is the entry of the program func main() { dict1 := make(map[string]int) dict2 := map[string]string{"Red": "#da1337", "Orange": "#e95a22"} colors := map[string]string{ "AliceBlue": "#f0f8ff", "Coral": "#ff7F50", "DarkGray": "#a9a9a9", "ForestGreen": "#228b22", } delete(colors, "Coral") for key, value := range colors { fmt.Printf("Key: %s Value: %s\n", key, value) } fmt.Println(dict1, dict2) }