Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 如何在字符串中添加换行符?_String_Line Breaks_Sml_Read Eval Print Loop - Fatal编程技术网

String 如何在字符串中添加换行符?

String 如何在字符串中添加换行符?,string,line-breaks,sml,read-eval-print-loop,String,Line Breaks,Sml,Read Eval Print Loop,问题在标题中 如果我在REPL中执行此操作(windows命令行中的SML/NJ) 我想 val x = "hello world" : string 或者类似的东西,但我 val x = "hello\nworld" : string 虽然我在某处发现\n是SML字符串中的换行符 显示字符串时,换行符显示为\n 但是,如果您尝试打印字符串,则会将其视为正确的换行符: - val x = "hello\nworld"; > val x = "hello\nworld" : string

问题在标题中

如果我在REPL中执行此操作(windows命令行中的SML/NJ)

我想

val x = "hello
world" : string
或者类似的东西,但我

val x = "hello\nworld" : string

虽然我在某处发现\n是SML字符串中的换行符

显示字符串时,换行符显示为
\n

但是,如果您尝试打印字符串,则会将其视为正确的换行符:

- val x = "hello\nworld";
> val x = "hello\nworld" : string
- print x;
hello
world> val it = () : unit
这只是字符串的显示方式,除非您自己打印,否则无法让SML解释器将其显示为实际的换行符。

如何
val x=“hello\\nworld”
- val x = "hello\nworld";
> val x = "hello\nworld" : string
- print x;
hello
world> val it = () : unit