【发布时间】:2014-02-07 10:27:09
【问题描述】:
我的程序有问题。它说:“`write':关闭的流(IOError)”。
def backup(dir, file, time="")
fullpath = "#{dir}/#{file}"
#puts fullpath
@f.puts "BKP_DATE: #{$date}"
@f.puts "BKP_DIRECTORY: #{dir}"
@f.puts "M_TIME: #{time}"
@f.puts "BKP_FILE: #{file}"
IO.readlines(fullpath).each do |line|
@f.puts line
end
@f.close()
end
【问题讨论】:
-
这里有什么问题?
-
也许您连续两次调用
backup而没有重新打开文件@f? -
在我的程序中,我调用了两次功能备份。 if self.backup(base, f, temps) != false puts self.backup(base, f, temps) end 他在 if 和 puts 中被调用。如果我评论 if... 我们可以暂停 Ruby 脚本吗? (例如 5 秒)。谢谢你的回答。