level 1
神灵武士SW
楼主
现需要实现以下功能:在D:\tpbase-contps\src\tests\tplib\test.txt 文件中检索D:\tpbase-contps\a 字符串,
我写的脚本如下:
file_name="D:\\tpbase-contps\\src\\tests\\tplib\\test.txt"
str="D:\\tpbase-contps\\a"
File.open(file_name, 'r') do |file|
until (line = file.gets).nil?
next if line.match(str).nil?
p "ok"
break
end
end
运行结果没有输出ok,我也尝试了str='d:\\...' 等各种方法还是不能解决,求教。
2016年04月06日 10点04分
1
我写的脚本如下:
file_name="D:\\tpbase-contps\\src\\tests\\tplib\\test.txt"
str="D:\\tpbase-contps\\a"
File.open(file_name, 'r') do |file|
until (line = file.gets).nil?
next if line.match(str).nil?
p "ok"
break
end
end
运行结果没有输出ok,我也尝试了str='d:\\...' 等各种方法还是不能解决,求教。
