【发布时间】:2009-08-02 08:46:50
【问题描述】:
我正在使用这个 REST Web 服务,它返回各种模板字符串作为 url,例如:
"http://api.app.com/{foo}"
在 Ruby 中,我可以使用
url = Addressable::Template.new("http://api.app.com/{foo}").expand('foo' => 'bar')
得到
"http://api.app.com/bar"
有没有办法在 Python 中做到这一点?我知道 %() 模板,但显然它们在这里不起作用。
【问题讨论】:
标签: python ruby templates string