为什么在mako中使用上下文?

2024-05-19 09:46:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我阅读了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()

什么样的利润使用环境?在


Tags: 代码namefromimportmakocontexttemplate手册

热门问题