bytes.Join的用法
摘要:
package main
import (
"bytes"
"fmt"
)
func main(){
hello := "hello"
helloBytes := []byte( hello )
fmt.Println( hello...
package main import ( "bytes" "fmt" ) func main(){ hello := "hello" helloBytes := []byte( hello ) fmt.Println( helloBytes ) world := "world" worldBytes := []byte( world ) fmt.Println( worldBytes ) helloWord := [][]byte{ helloBytes,worldBytes } fmt.Println( helloWord ) helloWords := bytes.Join(helloWord,[]byte{}) fmt.Println( helloWords ) }
執行結果如下:
[104 101 108 108 111] [119 111 114 108 100] [[104 101 108 108 111] [119 111 114 108 100]] [104 101 108 108 111 119 111 114 108 100]