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"
.
精彩评论