5-3 使用ioutil便捷读入

Posted paad

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)
    

 

以上是关于5-3 使用ioutil便捷读入的主要内容,如果未能解决你的问题,请参考以下文章