代码如下:
package main import "fmt" func main(){ var pc map[string] string pc = make(map[string] string) pc["qingdao"] = "青岛" pc["jinan"] = "济南" pc["yantai"] = "烟台" delete(pc,"qingdao") qingdao,ok := pc["qingdao"] if ok{ fmt.Println(qingdao) }else{ fmt.Println("元素不存在") } }
原创文章,作者:GNZAE,如若转载,请注明出处:https://www.beidanyezhu.com/a/28687.html