Ruby 读取文件

后端开发   发布日期:2025年06月29日   浏览次数:318

Ruby 读取文件

一次全读出来

textAll = File.read("fileName.txt")

puts textAll

一次读取一行

file = File.open("fileName.txt")

file.each_line {|line|

    puts line

}

file.close

以上就是Ruby 读取文件的详细内容,更多关于Ruby 读取文件的资料请关注九品源码其它相关文章!