我的代码:如何每个数组元素写入到不同的文件
allfiles = [123, 234, 345]
allurls = ["http://www.123.com", "http://www.234.com"]
for allfile in allfiles
name = allfile + ".html"
File.open(name, "w") do |file|
for allurl in allurls
file.write(RestClient.get(allurl))
end
end
end
Error: String can't be coerced into Fixnum (TypeError)
基本上,我想下载相应的URL的HTML,并将其保存到相应的其URL命名的文件。我的代码有什么问题?
谢谢!
尝试改变'名字= ALLFILE +名 “.html ”''到名字=(ALLFILE).to_s +名“ .html”' – Pavan