我在 golang 中有一堆字符串和 [] 字符串,我需要將它們連接起來。但是出于某種原因,我在此過程中遇到了很多需要擺脫的空格。這是代碼 tests := strings.TrimSpace(s[0]) dep_string := make ([]string, len(tests) + len(sfinal)) dep_string = append (dep_string,tests) for _,v := range sfinal { dep_string = append(dep_string,v) } fmt.Println("dep_String is ",dep_string)Input: s[0] = "filename"sfinal = [test test1]expected output[filename test test1]actual output[ filename test test1]這真的很奇怪;即使在使用 TrimSpace 之后,我也無法擺脫多余的空間。有沒有什么有效的方法來連接它們?
- 3 回答
- 0 關注
- 424 瀏覽
添加回答
舉報
0/150
提交
取消