我阅读了Makotemplate的手册,看到了以下代码:
from mako.template import Template
from mako.runtime import Context
from StringIO import StringIO
mytemplate = Template("hello, ${name}!")
buf = StringIO()
ctx = Context(buf, name="jack")
mytemplate.render_context(ctx)
print buf.getvalue()
什么样的利润使用环境?在
您可能不会直接使用它,它包含输出缓冲区和可以从模板中引用的变量字典。通常最好使用
render
的render
方法。在你可以阅读更多关于它的here。在
相关问题 更多 >
编程相关推荐