为什么io:格式支持〜n当\做同样的事情? [英] Why does io:format support ~n when \n does the same thing?

查看:100
本文介绍了为什么io:格式支持〜n当\做同样的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个输出相同:

1> io:format("Hello, world!~n").
Hello, world!
ok
2> io:format("Hello, world!\n").
Hello, world!
ok

为什么 io:format 支持〜n \\\
做同样的事情?有没有区别?

Why does io:format support ~n when \n does the same thing? Are there any differences?

推荐答案

根据编程Erlang,〜n 在Unix上输出特定于平台的新行序列( \\\
\r\\\
Windows等)。我认为 \\\
只是写了 \\\
字符,但不确定。

According to "Programming Erlang", ~n outputs the platform-specific new line sequence (\n on Unix, \r\n on Windows, etc.). I think \n just writes the \n character, but am not sure.

这篇关于为什么io:格式支持〜n当\做同样的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆