func main() { s := "Hello" b := []byte(s) fmt.Println(len(b), cap(b)) fmt.Println(b) }
5 8[72 101 108 108 111]
//字符串转换为字节
[]byte(s)
[]byte转换为 string 转换语法为string(bs)
[]byte
string(bs)