读书人

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

发布时间: 2013-10-22 16:16:51 作者: rapoo

paip.erlang 文本文件读写操作attilax总结
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 显然,换行符

读书人网 >网络基础

热点推荐