码迷,mamicode.com
首页 > 其他好文 > 详细

5-3 使用ioutil便捷读入

时间:2019-07-01 18:38:58      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:err   fun   string   文件的   content   pre   nil   ==   code   

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便捷读入

标签:err   fun   string   文件的   content   pre   nil   ==   code   

原文地址:https://www.cnblogs.com/paad/p/11115832.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!