我正在尝试使用字符串的模函数%
来获取哈希并将其值注入字符串内的适当位置,但key{x} not found (KeyError)
即使我可以确认密钥在那里,我也总是收到。我究竟做错了什么?
s = "Invalid: %{totalInvalid} , OutofThreshold: %{totalOutOfThreshold} "
puts row.fetch ('totalInvalid') #<-Just checking to make sure the key is in there
ext = s % row
我得到这个输出:
0 #<- Key does seem to be in there, returns correct value
in `%': key{totalInvalid} not found (KeyError)
哈希是从微型 tds (命中 SQL 服务器)提供的,并且当在其上使用 puts 时:
{"environment"=>"prd ", "locale"=>"uk ", "totalProducts"=>666, "to
talOutOfThreshold"=>0, "totalInvalid"=>0, "epochtime"=>1444444444, "thresholdPro
ductIds"=>"", "invalidProductIds"=>""}