ruby 去掉文件里重复的行 2020-02-16 分类:Ruby 标签Tags:ruby,去掉,文件,重复,old,file,open,argv,collect,n,ew,a,i,length,write,uniq,end,简单
old = File.open(ARGV[0]).collect new = File.open(ARGV[1],"a+") for i in 0..old.length-1 new.write(old.uniq[i]) end ##或简单两行也可以如qc.rb old = File.open(ARGV[0]).collect puts old.uniq 然后qc.rb dic.dic >new.dic 以上就是【ruby 去掉文件里重复的行】的全部内容了,欢迎留言评论进行交流!