paip.erlang 文本文件读写操作attilax总结

来源:互联网 发布:英语翻译软件哪个好 编辑:程序博客网 时间:2024/05/21 17:05
paip.erlang 文本文件读写操作attilax总结


作者Attilax ,  EMAIL:1466519819@qq.com 
来源:attilax的专栏
地址:http://blog.csdn.net/attilax


///////////halo.erl


main(_) -> 
    io:format("Hello worldnx"),
    {ok, S} = file:open("test2.dat", write),
io:format(S, "~s~n", ["Hello readers"]),
io:format(S, "~w~n", [123]).


/////////运行
"D:\Program Files\erl5.10.3\bin\escript.exe"  "D:\Program Files\erl5.10.3\halo.erl"


/////////结果
C:\Documents and Settings\Administrator\test2.dat 文件内容
Hello readers
123








////说明
其中的~开头的字符是一个个格式化命令,比如常见的:
~c   anscii码
~f   浮点数
~s   字符串
~w   Erlang term
~p   与~w类似,不过当多行时将自动换行
~n   显然,换行符

原创粉丝点击