Noobie问题:)
如何将列表数据结构转换为Elixir中的字符串?
示例:
["all"] # into "['all']"
["project", "labels"] # into "['project', 'labels']"
答案 0 :(得分:2)
我没有声称唯一正确的决定,但也许这会有所帮助:
iex(13)> a = ['project', 'labels']
['project', 'labels']
iex(14)> b = inspect a
"['project', 'labels']"
但对于双引号srting:
iex(21)> c = ["all"]
["all"]
iex(22)> d = inspect(c) |> String.replace("\"", "'")
"['all']"
因为"all"
是二进制文件,但'all'
是char_list。来自here