golang map删除元素

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("元素不存在")
     }
 }

 

你可能感兴趣的:(golang map删除元素)