如何在Lisp中创建和写入文本文件 [英] How to create and write into text file in Lisp
本文介绍了如何在Lisp中创建和写入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想写简单的一行:
break 1
break 2
我在Window 7上使用LispWorks IDE
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ :if-exists:supersede
:if-does-exist-exist:create)
(format strwrite anything〜%))
:if-does-exist-exist:create)
(format strwrite anything〜%))
您也可以为 with-open-file
宏选择不同的设置。如果您使用:append
而不是:supersede
,那么您可以写入文本文件,同时保留上下文而不是替代可用的内容。
I want to know, how to create and write text file in lisp. I just want to write simple line like:
"break 1"
"break 2"
I am using LispWorks IDE on Window 7
解决方案
(with-open-file (str "/.../filename.txt"
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(format str "write anything ~%"))
You may also choose different settings for the with-open-file
macro. If you use :append
instead of :supersede
then you can write into the text file while preserving its context instead of superseding the available content.
这篇关于如何在Lisp中创建和写入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文