![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Ruby
文章平均质量分 52
天然居
这个作者很懒,什么都没留下…
展开
-
Ruby正则中文汉字
1.puts /[一-龥]+/.match("this is 中文") =>中文2.str2="123中文"puts /\p{Han}+/u.match(str2) # /u是utf-8/a/.encoding # US-ASCII/a/u.encoding # UTF-8Ruby 和部分语言可以直接 #{Han原创 2015-08-17 14:25:49 · 1904 阅读 · 0 评论 -
Ruby遍历文件夹
原先需要自己手写一个递归算法:def traverse_dir(file_path) if File.directory? file_path Dir.foreach(file_path) do |file| if file !="." and file !=".." traverse_dir(file_path+原创 2015-09-11 19:05:48 · 6210 阅读 · 0 评论 -
Ruby对excel读写操作
0.读取本地文件两个方法: file = open(path) lines = file.readlines lines.each do |line| p line #" BOOST = self.new(1, '觉醒之书')\n" end file = File.open(filePath, "r") file.each_line do |line|原创 2015-09-14 10:56:19 · 3176 阅读 · 0 评论 -
Ruby笔记
Hash:Ruby的key-value数据结构就是Hash。如 myhash = {2 => 5, "he" => "ggg"};经常要对hash排序,如metrics = {"sitea.com" => 745, "siteb.com" => 9, "sitec.com" => 10 }metrics.sort_by {|_key, value| value} # ==>原创 2016-01-14 18:06:13 · 346 阅读 · 0 评论