5-3 使用ioutil便捷读入

package main

import (
    "fmt"
    "io/ioutil"
)



func main() {
    //读入制定文件的全部数据,返回[]byte类型的原始数据
    bytes, err := ioutil.ReadFile("C:/Users/Administrator/Desktop/eth地址.txt")
    if err == nil {
        //使用string强制转化为字符串
        content := string(bytes)
        fmt.Println(content)
    }else {
        fmt.Println("文件读入失败,err=",err)
    }
}

猜你喜欢

转载自www.cnblogs.com/paad/p/11115832.html
5-3