Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.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
如何在scheme中向没有引号的文件写入字符串_Scheme_Chicken Scheme - Fatal编程技术网

如何在scheme中向没有引号的文件写入字符串

如何在scheme中向没有引号的文件写入字符串,scheme,chicken-scheme,Scheme,Chicken Scheme,我试图将一个字符串写入一个文件,但每次都有引号围绕 我试过了 (使用输出文件路径调用 (lambda(输出端口)(写入“某些文本”输出端口))) 及 (let((p(打开输出文件路径))) (写“一些文字”p) (关闭输出端口p)) 但在这两种情况下,我都希望看到“一些文本”,但得到了“一些文本” 我目前在chicken scheme工作,但我认为这无关紧要。write用于将S表达式序列化到文件中。它与read相反,后者将序列化的S表达式读回列表、符号、字符串等。这意味着write将像在源代

我试图将一个字符串写入一个文件,但每次都有引号围绕

我试过了

(使用输出文件路径调用
(lambda(输出端口)(写入“某些文本”输出端口)))

(let((p(打开输出文件路径)))
(写“一些文字”p)
(关闭输出端口p))
但在这两种情况下,我都希望看到
“一些文本”
,但得到了
“一些文本”


我目前在chicken scheme工作,但我认为这无关紧要。

write
用于将S表达式序列化到文件中。它与
read
相反,后者将序列化的S表达式读回列表、符号、字符串等。这意味着
write
将像在源代码中一样输出所有内容

如果只想将字符串输出到端口,请使用
display

(call-with-output-file file-path
  (lambda(output-port)
    (display "some text" output-port)))
或者在CHICKEN中,您可以使用
printf
fprinf

(call-with-output-file file-path
  (lambda(output-port)
    (fprintf output-port 
             "Printing as s-expression: ~S, as plain string: ~A"
             "some text"
             "some other test")))
这将在文件中打印以下内容:

Printing as s-expression: "some text", as plain string: some other text

write
用于将S表达式序列化到文件中。它与
read
相反,后者将序列化的S表达式读回列表、符号、字符串等。这意味着
write
将像在源代码中一样输出所有内容

如果只想将字符串输出到端口,请使用
display

(call-with-output-file file-path
  (lambda(output-port)
    (display "some text" output-port)))
或者在CHICKEN中,您可以使用
printf
fprinf

(call-with-output-file file-path
  (lambda(output-port)
    (fprintf output-port 
             "Printing as s-expression: ~S, as plain string: ~A"
             "some text"
             "some other test")))
这将在文件中打印以下内容:

Printing as s-expression: "some text", as plain string: some other text

感谢sjamaan-我感到困惑,因为我所看到的示例都使用了write(这似乎是写入文件的正确词语),而display似乎更适合显示到stdout/console.:)感谢sjamaan-我感到困惑,因为我所看到的示例都使用了write(这似乎是写入文件的正确词语),而display似乎更适合显示到stdout/console.:)