我想在文本文件中读取并将其作为序列并传递给它。我该怎么做?
这是我到目前为止所做的:
(with-open-file (stream "filename.txt")
(format t "~a~%" (read-line stream)))
文本文件是这样的:
Hello this is a sentence.
Hello this is second sentence.
答案 0 :(得分:3)
(with-open-file (in "filename.txt")
(with-output-to-string (out)
(loop :for line := (read-line in nil) :while line :do
(write-line line out)))))