rubyÎļþ²Ù×÷
1¡¢ÎļþµÄ´ò¿ªÓë¹Ø±Õ
``r'' Read-only, starts at beginning of file (default mode).
``r+'' Read-write, starts at beginning of file.
``w'' Write-only, truncates existing file to zero length or creates a new file for writing.
``w+'' Read-write, truncates existing file to zero length or creates a new file for reading and writing.
``a'' Write-only, starts at end of file if file exists, otherwise creates a new file for writing.
``a+'' Read-write, starts at end of file if file exists, otherwise creates a new file for reading and writing.
``b'' (DOS/Windows only) Binary file mode (may appear with any of the key letters listed above).
ʹÓÃfile.new·½·¨»ñȡһ¸öÎļþ¾ä±úÀ´¶ÔÎļþ²Ù×÷£¬²Ù×÷½áÊøºófile.closeÀ´¹Ø±ÕÎļþ¡£
file.open·½·¨ÊÇnew·½·¨µÄÀ©³ä£¬¸Ã·½·¨¿ÉÓдúÂë¿é£¬¸Ã´úÂë¿é½áÊøºó×Ô¶¯close£¬¶øÇÒÔÚ²Ù×÷¹ý³ÌÖз¢Éú´íÎóʱÄܹ»×Ô¶¯ÊÕ¼¯´íÎó²¢ÍƳö
Èç
file.open("filepath") do |file|
file.each do |line| ... end
end
һЩÎļþµÄ³£ÓÃÃüÁ
File.open(dir+"/read.txt","w") do |file|
file.puts("djkjsadlkjdkdsfdsee")
end puts File.exists?(dir+"/read.txt") ÎļþÊÇ·ñ´æÔÚ
puts File.directory?(dir+"/read.txt") ÎļþÊÇ·ñÊÇĿ¼·¾¶
puts File.file?(dir+"/read.txt") ÊÇ·ñÊÇÎļþ
puts File.zero?(dir+"/read.txt") ÎļþÄÚÈݳ¤¶ÈÊÇ·ñΪ0
puts File.size(dir+"/read.txt") »ñÈ¡Îļþ´óС
put
Ïà¹ØÎĵµ£º
×î½ü¿´ÁË¿´Perl£¬Ö÷ÒªÊÇÏë¿´¿´Ruby¶¼´ÓPerlÄÇÄÃÀ´ÁËЩʲô¡£Í¬Ê±£¬Ò²ÊÇÎÒѧϰPerlµÄһƪ±Ê¼Ç¡£
Ϊʲô´ó¼Ò¶¼ÊÇPerlµÄ´úÂë³óª£¬ÊÇʲôµ¼ÖÂÁËPerl³ÌÐò»ÞɬÄѶ®£¬RubyÖÐÓÖÊÇÈçºÎÈ¡ÉáÕâÐ©ÔªËØµÄÄØ£¿ÎÒÈÏΪPerlÉçÇø×·Çó¸üÉÙ´úÂëµÄ·çÆøÖú³¤ÁË´óÁ¿Ê¹ÓÃÔ¤Éè±äÁ¿µÄ·çÆø£¬´Ó¶øµ¼ÖÂÁËPerl´úÂëµÄ»Þɬ¡£
ÏÂÃæµÄÿ¸öPerlµÄÀý×Ó×ܰéÓÐ ......
Ó¢ÎÄ×ÊÔ´£º
http://www.ruby-lang.org/
http://www.ruby-doc.org£¨·ÃÎʲ»µ½¿ÉÓÃÏÂÃæµÄÍøÖ··ÃÎÊ£©£º
http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.ruby-doc.org
http://rubyforge.org/
http://www.ruby-forum.org/bb
http://www.rubygarden.org/ruby
http://www.rubyxml.com/
http://www.pragmaticprogra ......
·ÖΪÈçϼ¸½Ú:
·»ù±¾ÊµÏÖ
·ÔÚµü´úÖÐÒýÓÃÔÀ´µÄ¶ÔÏ󣬻òÕßÖ±½Ó¸Ä±äÊý×éµÄÖµ¶ø²»ÊÇ·µ»ØÒ»¸öÐÂÊý×é
·Ïòµü´ú´«ÈëÎÞÏÞ¶àµÄ²ÎÊý
·»ù±¾ÊµÏÖ
½ñÌìͻȻ·¢ÏÖjsµÄÊý×é´¦ÀíÆðÀ´ÕæÊÇÂé·³,´úÂëһЩ¾ÍÊÇÒ»´ó¶Ñ,Ïà±ÈÆðrubyµÄµü´úÆ÷À´ÕæÊÇÑ·É«²»ÉÙ,Ö÷ÒªÊÇҪдµÄ´úÂëÌ«¶àÁË,Ò²ÐíÊÇjsÓÐÌØÊâµÄ´¦ÀíÊý×éµÄ·½Ê ......
ÓÃrubyн¨Ò»¸öexcelÎļþ£¬²¢ÇÒÉèÖÃһЩֵ¡£
require 'win32ole'
excel = WIN32OLE.new("excel.application")
excel.Visible = true
excel.WorkBooks.Open("d:\\test.xls")
excel.WorkSheets("sheet1").Activate
excel.Cells(2,3).value = "ÕÅÈý"
exce ......
def delVss(path)
if File.directory?(path)
for f in d = Dir.open(path)
fpath = File.join(path, f)
if(f!="."&&f!="..")
......