修正后代码:
```go
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
var (
array3 [3]int
err error
)
rea := bufio.NewReader(os.Stdin)
list1, _ := rea.ReadString('\n')
var array2 = strings.Split(list1, " ")
for i, vl := range array2 {
vl = strings.Trim(vl, "\n") // 去除一下空格
array3[i], err = strconv.Atoi(vl)
if err != nil {
fmt.Printf("err: %v", err)
os.Exit(1)
}
}
fmt.Println("读到的数据", array3)
}
```
#5
更多评论
调试一下吧,`strconv.Atoi`返回的错误咋就随随便便忽略了啊。
![image.png](https://static.studygolang.com/210914/d71b5bf68dd203feba7f653f1b72cba6.png)
#1