例子:
file, err := os.Open("filename")
if err != nil {
//error handing
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
Scan() 默认对每行进行读取,可利用for语句进行循环遍历文件
Text() 将scanner读取的内容变为string