【发布时间】:2016-02-14 16:17:06
【问题描述】:
在下面的代码中,我希望读取一个文本文件,其中每行填充数字 1-5。我希望它扫描该行并读取其中一个值并查看其是否
//This is the part of the program that will read from a text file named "file"
//To see what numbers were selected last time so the recipe for week two can be
//a completely new recipe group of 5
f, err := os.Open("file")
if err != nil {
fmt.Println(err)
}
for {
var z int
var n int
n, err = fmt.Fscanln(f, &z)
if n == 0 || err != nil {
break
}
fmt.Println("int z :", z)
}
【问题讨论】: