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文件... –