dtml3340 2018-01-07 21:33
浏览 1186
已采纳

Golang:连接int数组

Initial data:

rawdata := []int{17, 23, 100500}

Result:

result := convert(rawdata)
expected := "1723100500"

What should I do with convert()? I have:

func convert(param []int) string {
    data := strings.Join(param)
    return data
}

but it is not work

  • 写回答

1条回答 默认 最新

  • dongyou9721 2018-01-07 21:43
    关注

    You should use the function strconv.Itoa or the fmt.Sprintf("%d",a)

    So like this

    S := ""
    for _,i := range intarray {
       S = S + strconv.Itoa( i )
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?