如何快速最优的获取文件的路径
file_path="D:/android_source/fdmakm/你好/Ruby/w/ok.txt"如何 获取 文件的路径 "D:/android_source/fdmakm/你好/Ruby/w/"?
用最优的方式?
谢谢! 本帖最后由 coolesting 于 2011-11-04 12:09 编辑
gsub, sqlit, Dir[] 回复 2# coolesting
谢谢,其余的 童鞋 还有没有别的方法呀? path="D:/android_source/fdmakm/你好/Ruby/w/ok.txt"
#这是官方的写法
File.split(path).first
#D:/android_source/fdmakm/你好/Ruby/w 回复 4# coolesting
可是,我这边一直报错:
SyntaxError: E:\eclipse-ws\helloword-ruby\test_map.rb:157: invalid multibyte char (US-ASCII)。
编码 问题的 这种情况如何避免呢? 回复coolesting
可是,我这边一直报错:
SyntaxError: E:\eclipse-ws\helloword-ruby\test_ ...
i_love_ruby 发表于 2011-11-05 01:36 http://bbs.chinaunix.net/images/common/back.gif
解决了,一般在文件的开头加上:
#encoding:utf-8
页:
[1]