这很好用:
@H_502_13@#!/usr/bin/rubyrequire 'httpclIEnt'http2 = httpClIEnt.newresponse = http2.get_content("http://example.com/version.ini")response.each_line do | line | http = httpClIEnt.new my_file = open('file.zip','wb') my_file.write(http.get_content("http://example.com/data.zip"))endputs "Done."但这不是:
@H_502_13@#!/usr/bin/rubyrequire 'httpclIEnt'http2 = httpClIEnt.newresponse = http2.get_content("http://example.com/version.ini")response.each_line do | line | puts line # -> file.zip http = httpClIEnt.new my_file = open(line,'wb') my_file.write(http.get_content("http://example.com/data.zip"))endputs "Done."安慰:
解决方法 问题是使用换行符char,尝试剥离它. @H_502_13@my_file = open(line.chomp,'wb') 总结C:/Ruby22-x64/lib/ruby/2.2.0/open-uri.rb:36:in
initialize': InvalID
open’
argument @ rb_sysopen - file.zip (Errno::EINVAL)
from C:/Ruby22-x64/lib/ruby/2.2.0/open-uri.rb:36:in
from C:/Ruby22-x64/lib/ruby/2.2.0/open-uri.rb:36:inopen'
block in ‘
from launcher.rb:10:in
from launcher.rb:7:ineach_line'
‘
from launcher.rb:7:in
以上是内存溢出为你收集整理的ruby – 使用字符串到文件名全部内容,希望文章能够帮你解决ruby – 使用字符串到文件名所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)