Join

Join 将一系列字符串连接为一个字符串,之间用sep来分隔。

Join

函数定义

func Join(elems []string, sep string) string

代码示例

package main

import (
    "fmt"
    "strings"
)

func main() {
    s := []string{"foo", "bar", "baz"}
    fmt.Println(strings.Join(s, ",")) //foo,bar,baz
    fmt.Println(strings.Join(s, ", ")) //foo, bar, baz
}