String 如何在字符串中添加换行符?
问题在标题中 如果我在REPL中执行此操作(windows命令行中的SML/NJ) 我想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
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