运行 ❯
获取自己的
网站
×
更改朝向
更改主题,深色/浅色
前往 Spaces
package main import ("fmt") func main() { var a = map[string]string{"brand": "Ford", "model": "Mustang", "year": "1964", "day":""} val1, ok1 := a["brand"] // Checking for existing key and its value val2, ok2 := a["color"] // Checking for non-existing key and its value val3, ok3 := a["day"] // Checking for existing key and its value _, ok4 := a["model"] // Only checking for existing key and not its value fmt.Println(val1, ok1) fmt.Println(val2, ok2) fmt.Println(val3, ok3) fmt.Println(ok4) }
福特为 true
false
true
true