GO语言bytes包Join函数的用法及代码示例。

用法:

func Join(s [][]byte, sep []byte) []byte

Join将s的元素连接起来以创建一个新的字节片。分隔符sep放置在所得切片中的元素之间。

▾示例

package main

import (
    "bytes"
    "fmt"
)

func main() {
    s := [][]byte{[]byte("foo"), []byte("bar"), []byte("baz")}
    fmt.Printf("%s", bytes.Join(s, []byte(", ")))
}

输出:

foo, bar, baz
Process finished with the exit code 0

相关文章:

  • 2021-09-12
  • 2022-12-23
  • 2021-11-22
  • 2023-03-20
  • 2022-12-23
  • 2023-04-02
猜你喜欢
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2023-03-18
  • 2021-08-14
  • 2022-12-23
相关资源
相似解决方案