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

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

golang 刪除數組的一個維度

golang 刪除數組的一個維度

Go
Cats萌萌 2021-07-09 18:55:46
我在 golang 中有這樣的代碼func GetIndexes(body string) ([]int, error) {    indexPattern, err := regexp.Compile(`<div class="post article" id="([0-9]+)">`)    res := indexPattern.FindAllStringSubmatch(body, -1)    fmt.Printf("%v\n", res)    //Just for debug    return make([]int, 5), err}例如,結果如下:[ [<div class="post article" id="55987"> 55987] [<div class="post article" id="6717024"> 6717024] [<div class="post article" id="6440542"> 6440542] [<div class="post article" id="6800745"> 6800745] [<div class="post article" id="449954"> 449954] [<div class="post article" id="427586"> 427586] [<div class="post article" id="5418445"> 5418445] [<div class="post article" id="559225"> 559225]... ]我正在尋找一種方法來獲得像這樣的數組[55987, 6717024, 6717024, ...] 我可以調整我要查找的數組和復制值的范圍,但我不確定這是更好的方法。這就是為什么我問自己是否可以刪除此數組的列,或者為什么不使用 lambdas 函數或其他函數創建某種切片...
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 340 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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