問題從地圖獲取數據數據格式res = map[Event_dtmReleaseDate:2009-09-15 00:00:00 +0000 +00:00 Trans_strGuestList:<nil> strID:TSTB]筆記如何從上面的結果中得到以下值Event_dtmReleaseDatestrIDTrans_strGuestList我試過的:res.Map("Event_dtmReleaseDate");錯誤:res.Map 未定義(類型 map[string]interface {} 沒有字段或方法 Map)res.Event_dtmReleaseDate;錯誤:v.id 未定義(類型 map[string]interface {} 沒有字段或方法 id)
2 回答

Helenr
TA貢獻1780條經驗 獲得超4個贊
一般來說,要從地圖中獲取價值,您必須執行以下操作:
package main
import "fmt"
func main() {
m := map[string]string{"foo": "bar"}
value, exists := m["foo"]
// In case when key is not present in map variable exists will be false.
fmt.Printf("key exists in map: %t, value: %v \n", exists, value)
}
結果將是:
key exists in map: true, value: bar
- 2 回答
- 0 關注
- 196 瀏覽
添加回答
舉報
0/150
提交
取消