在下面的代码中,我希望读取每行填充有 1-5 个数字的文本文件。我希望它扫描该行并读取其中一个值,看看它是否 < 6 并执行操作。不幸的是,我无法获取一部分值,它们仅作为数组打印。关于如何修复我的代码的任何建议?
//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)
}
RISEBY
相关分类