0
同時插入內容到一個文件:文件顯示錯誤
file1=File.new("output.txt","w+")
puts "enter the string"
in1=gets.chomp
if file1
file1.syswrite()
else
puts cant write
end
file1.close
同時插入內容到一個文件:文件顯示錯誤
file1=File.new("output.txt","w+")
puts "enter the string"
in1=gets.chomp
if file1
file1.syswrite()
else
puts cant write
end
file1.close
試試這個,它使用的File class的write
方法。記住,當你寫一個看跌語句,隨後的字符串需要加引號。
file1=File.new("output.txt","w+")
puts "enter the string"
in1=gets.chomp
if file1
file1.write(in1)
else
puts "can't write"
end
file1.close
謝謝.. bajwa –
不用擔心,你能接受答案嗎? –
什麼錯誤?爲什麼lowlevel'syswrite'? – mudasobwa
過去的錯誤,請 –
我需要寫的內容,目前在in1文件... –