【发布时间】:2021-09-27 11:56:06
【问题描述】:
我想将一个字符串数组传递给 Mako 的渲染方法,但这不起作用:
from mako.template import Template
mytemplate = Template(filename="some.template")
str = mytemplate.render(first="John", last="Smith", nicknames=[
"JJ", "Johnny", "Jon"])
print(str)
some.template =
Hello ${first} ${last}
Your nicknames are:
% for n in ${nicknames}:
${n}
% endfor
【问题讨论】: