我有一个包含嵌入的"字符的字符串:
tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">
我该如何在Elixir中将这样的字符串作为值呈现?
例如:
iex> s= "tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">"
使用 ~s 和 ~S 没有帮助
iex(20)> s=~S("tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">")
** (SyntaxError) iex:20: keyword argument must be followed by space after: w:
iex(20)> s=~s("tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">")
** (SyntaxError) iex:20: keyword argument must be followed by space after: w:
iex(20)>
File.Stream
将自动转义引号。例如:iex(4)> IO.gets ">"; >""" "TEST "" "; "\"\"\" \"TEST \"\" \"\n"
- Gazlers" 和 "S" 无法工作,请查看上面编辑问题时报告的错误。 - Charles Okwuagwu~
前面加上一个空格 -s = ~s(...)
而不是s=~s(...)
。 - Gazler