文档介绍:目录新建文件语句: 1关闭文件语句: 1打开文件语句: 2打开文件及文件内容: 2建立新文件 3Ruby类型转换函数及示例 4Ruby单行注释 5Ruby多行注释 5Ruby中的常用分隔符如下: 6ruby中的运算符如下:优先级(由高到低) 7新建文件语句:File=(”C:/”,”w”)File=(”C:/”,”r”)File=(”C:/”,”w+”)File=(”C:/”,”r+”)读取文件语句::out=("","w")  :file=("transactions","w")("somefile","w")do|file|  "Line1"  "Line2"  "Thirdandfinalline"  end+号的应用f1=("file1","r+")  #Read/write,startingatbeginningoffile.  f2=("file2","w+")  #Read/write;truncateexistingfileorcreateanewone.  f3=("file3","a+")  #Read/write;startatendofexistingfileorcreatea  #newone.“r”“w”“w+”“r+””a””a+””b”解释如下``r''Read-only,startsatbeginningoffile(defaultmode).   ``r+''Read-write,startsatbeginningoffile.   ``w''Write-only,truncatesexistingfiletozerolengthorcreatesanewfileforwriting.   ``w+''Read-write,truncatesexistingfiletozerolengthorcreatesanewfileforreadingandwriting.   ``a''Write-only,startsatendoffileiffileexists,otherwisecreatesanewfileforwriting.   ``a+''Read-write,startsatendoffileiffileexists,otherwisecreatesanewfileforreadingandwriting.   ``b''(DOS/Windowsonly)Binaryfilemode(mayappearwithanyofthekeyletterslistedabove).打开文件及文件内容:("filepath")do|file|       |line|...end   (dir+"/","w")do|file|