一起学习网 一起学习网


ruby 去掉文件里重复的行

网络编程 ruby 去掉文件里重复的行 06-22
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 rails 页面跳转(render和redirect_to)
Ruby代码if@user.update_attributes(:password=params[:user][:password])flash[:notice]='密码修改完成'redirect_to:action='index'elseredirect_to:action='change_pass',:id=@userend后来随手改了

Ruby 取得指定月日期数的方法
代码如下:require'date'day=Date.new(2008,2,-1)end_of_month=day.strftime('%d').to_iyear_and_month=day.strftime('%Y%m')fortodayin1..end_of_monthdopsprintf('%s%02d',year_and_month,today)end其他

Ruby 中关于日文转UTF-8及半角全角转换的技巧
1.日文转UTF-8Iconv.new('cp932','utf-8')与Iconv.new('shift_jis','utf-8')的区别Iconv.new('shift_jis','utf-8')不支持以下的格式:?№001-18XXXXXXX而只能把字符窜中的№换成No.才


编辑:一起学习网

标签:日文,全角,代码,期数,半角