「Ruby」getsを使用してファイルを1行ずつ読み込むサンプル
構文
fp = open(“テキストファイル名")
while line = fp.gets
getsを使用して、ファイルを1行ずつ読み込みます。
使用例
fp = open("test.txt")
while line = fp.gets
  p line
end
fp.close
Coding Changes the World
構文
fp = open(“テキストファイル名")
while line = fp.gets
getsを使用して、ファイルを1行ずつ読み込みます。
使用例
fp = open("test.txt")
while line = fp.gets
  p line
end
fp.close