输入:
// a slice of type string.
data := []string{"one", "two", "three"}
Run Code Online (Sandbox Code Playgroud)
预期输出:
["one","two","three"]
Run Code Online (Sandbox Code Playgroud)
我尝试使用这些格式说明符 https://play.golang.org/p/zBcFAh7YoVn
fmt.Printf("%+q\n", data)
fmt.Printf("%#q\n", data)
fmt.Printf("%q\n", data)
// using strings.Join()
result := strings.Join(data, ",")
fmt.Println(result)
Run Code Online (Sandbox Code Playgroud)
输出: 所有值都没有逗号,
["one" "two" "three"]
[`one` `two` `three`]
["one" "two" "three"]
one,two,three
Run Code Online (Sandbox Code Playgroud)