string:join/2
通过一个分隔符把字符列表连接起来
用法:
join(StringList, Separator) -> String
内部实现:
-spec join(StringList, Separator) -> String when StringList :: [string()], Separator :: string(), String :: string(). join([], Sep) when is_list(Sep) -> []; join([H|T], Sep) -> H ++ lists:append([Sep ++ X || X <- T]).
通过一个分隔符 Separator,把一个字符列表 StringList 里的元素连接起来
string:join(["a", "b", "c", "d"], "-").
string:join(["a", "b", "c", "d"], "").