我使用这个REST Web服务,它返回不同的模板字符串作为URL,例如:Python字符串templater
"http://api.app.com/{foo}"
在Ruby中,我可以再使用
url = Addressable::Template.new("http://api.app.com/{foo}").expand('foo' => 'bar')
得到
"http://api.app.com/bar"
有什么办法可以在Python中做到这一点?我知道%()模板,但显然他们不在这里工作。