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

golang []byte和string相互转换

时间:2017-04-08 09:51:39      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:package   style   port   int   class   imp   blog   golang   import   

测试例子

package main
 
import (
    "fmt"
)
 
func main() {
    str2 := "hello"
    data2 := []byte(str2)
    fmt.Println(data2)
    str2 = string(data2[:])
    fmt.Println(str2)
}

 

golang []byte和string相互转换

标签:package   style   port   int   class   imp   blog   golang   import   

原文地址:http://www.cnblogs.com/DaBing0806/p/6680750.html

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