2
我在Go的exec.Command的幫助下使用第三方工具,該程序將打印出一個很大的整數值,這顯然是字符串格式。我無法將該字符串轉換爲int(或更具體的uint64)。解析Go命令問題()。Output()
詳情: (你可以忽略它是什麼節目等,但運行後,它會返回我一個大的整數)
cmd := exec.Command(app, arg0, arg1, arg3)
stdout, err := cmd.Output()
if err != nil {
fmt.Println(err.Error())
return
}
temp := string(stdout)
後,我跑了上面,我想對它進行解析如下
這裏myanswer, err = strconv.Atoi(temp) //I know this is not for uint64 but I am first trying for int but I actually need uint64 conversion
if err != nil {
fmt.Println(err)
return
}
問題是,標準輸出附加\ r \ n至它的輸出,ATOI無法解析,並給出了錯誤
strconv.Atoi:解析「8101832828 \ r \ n」:無效語法
有人可以幫助我如何將此字符串輸出轉換爲uint64和int格式pls?
此鏈接幫助我!對不起dup問題http://stackoverflow.com/questions/37757683/parsing-integer-from-exec-command-output – Innocentguy