亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從戈朗的數組中逐個打印結果?

如何從戈朗的數組中逐個打印結果?

Go
一只甜甜圈 2022-09-26 14:19:59
在此代碼中,我根據電子郵件和密碼查找數據。但我想做另一件事,那就是使用 a 并逐個打印數組數據。for loopresult給定結果Found a single document: {Name:bilal Email:[email protected] Password:bilalo Business:computer company}預期成果Name:bilal Email:[email protected] Password:1234 Business:computer company法典// Find data in database based on email and passwordvar result Storecollection := client.Database("PMS").Collection("dataStored")if err = collection.FindOne(context.TODO(), bson.M{"email": myEmail, "password": myPassword}).Decode(&result); err != nil {    log.Fatal(err)}fmt.Printf("Found a single document: %+v\n", result)for _, results := range &result {    fmt.Println(results)}
查看完整描述

1 回答

?
素胚勾勒不出你

TA貢獻1827條經驗 獲得超9個贊

在循環之前嘗試此操作printf

fmt.Printf("Name:%v \nEmail:%v \nPassword:%v \nBusiness:%v \n", result.Name, result.Email, result.Password, result.Business)



查看完整回答
反對 回復 2022-09-26
  • 1 回答
  • 0 關注
  • 74 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號