开发者

How to render file-based template with arguments?

from mako.template import Template

stext = "hi"

mytemplate = Template(filename='./t开发者_StackOverflow社区.txt')
print mytemplate.render()

t.txt:

${hi}  , i am here


Replace the last line with:

mytemplate.render(hi = "world")

Now, hi can equal anything you like, not just "world".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜