标签: ruby-on-rails ruby
我做什么
str= " John Smith Beer " str.tr(" ", "%20") "%%John%%%Smith%Beer%"
它不能用"%20"替换它。 如何解决?
答案 0 :(得分:16)
require 'uri' URI.encode("green books") # => "green%20books"