· software
Ruby 文件处理和系统命令
打开并读取文件 ```ruby File.open 'p014constructs.rb', 'r' do |f1| while line = f1.gets puts line end end ``` 写入文件 ```ruby File.open 'test.rb', 'w' do |f2| f2.puts 'Created by...' end ```
打开并读取文件 ```ruby File.open 'p014constructs.rb', 'r' do |f1| while line = f1.gets puts line end end ``` 写入文件 ```ruby File.open 'test.rb', 'w' do |f2| f2.puts 'Created by...' end ```