简体   繁体   中英

Writing a tuple in file in erlang

How to write a tuple in file in erlang.What i have tried so far is

Result={1,"OK",3},
file:write_file("/tmp/logs.txt", Result, [append])

But it is giving bad args error. Any solutions??

file:write_file takes an iolist, not a plain Erlang term. You could format the term as an iolist using io_lib:format :

file:write_file("/tmp/logs.txt", io_lib:format("~p.~n", [Result]), [append])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM