我正在制作一个随机的猫图片饼干,并认为 Ruby 是最好的。这段代码,
require 'chunky_png'
require 'open-uri'
d=rand(2000)+1
url="http://www.placekitten.com/"
open('image.png', 'wb') do |file|
file << open(url,d).read
end
这可能是一个非常容易解决的问题,但我是 ruby 新手....运行它时出现此错误
C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:146:in
open_uri': invalid access mode 200 (URI::HTTP resource is read only.) (ArgumentError) from C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:688:in
open' 从 C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:34:inopen' from Kittens.rb:8:in
块中'来自 C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:36:inopen' from C:/Ruby200/lib/ruby/2.0.0/open-uri.rb:36:in
open' 来自 Kittens.rb:7:in `'