puts '输入要解析的文件名:'
fileImp = STDIN.gets
logfile = File.new('temp.txt','a')
File.open(fileImp)do|file|
until file.eof?
logfile.puts file.gets.strip.gsub(/[\s]/,',')
end
logfile.close
end
执行以上代码
----------------------------
输入要解析的文件名:
2.txt
----------------------------
报错信息:
test.rb:5:in `initialize': Invalid argument - 2.txt (Errno::EINVAL)
from test.rb:5:in `open'
from test.rb:5
如果打开文件时写死了就没有问题
File.open('2.txt')
哪位给我解释解释好么??