ruby使用IO类读写文件

后端开发   发布日期:2025年06月28日   浏览次数:228
path="test.txt"
port=open(path)
begin
    port.each_line{|line|
        p line.to_s
    }
ensure
    port.close
end
STDOUT << "i love you \n"
port=open('test.txt')
s=port.stat
p s.ftype
p s.dev
p s.ino
p s.mode
p s.nlink
begin
    a=port.readlines
    a=port.each{|e| p e}
    ensure
        port.close
    end

 

                      

以上就是ruby使用IO类读写文件的详细内容,更多关于ruby使用IO类读写文件的资料请关注九品源码其它相关文章!