「Ruby」openでテキストファイルを読み取るサンプル

2021年8月29日

書式
open(ファイル名)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
f = open("test007.txt")
while strLine = f.gets
p strLine
end
f.close
f = open("test007.txt") while strLine = f.gets p strLine end f.close
f = open("test007.txt")
 
while strLine = f.gets
  p strLine
end
 
f.close

 

Ruby

Posted by arkgame