【发布时间】:2019-09-19 15:03:45
【问题描述】:
我可以读取一个文件并根据这样的谓词找到一个特殊的行
open(file, read=true, write=true, append=true) do io
for line in eachline(io)
if predicate(line)
new_line = modifier(line)
# how to replace the line with new_line in the file now?
end
end
end
但是我现在如何更改文件中的内容呢?
【问题讨论】: