[英]Writing a tuple in file in erlang
How to write a tuple in file in erlang.What i have tried so far is 如何在erlang中编写文件中的元组。到目前为止我尝试过的是
Result={1,"OK",3},
file:write_file("/tmp/logs.txt", Result, [append])
But it is giving bad args error. 但它给出了错误的args错误。 Any solutions?? 有解决方案??
file:write_file
takes an iolist, not a plain Erlang term. file:write_file
采用iolist,而不是简单的Erlang术语。 You could format the term as an iolist using io_lib:format
: 您可以使用io_lib:format
术语作为io_lib:format
:
file:write_file("/tmp/logs.txt", io_lib:format("~p.~n", [Result]), [append])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.