【发布时间】:2010-11-05 00:33:49
【问题描述】:
有人知道如何用 Mako 格式化字符串的长度吗?
相当于print "%20s%10s" % ("string 1", "string 2")?
【问题讨论】:
标签: python template-engine mako
有人知道如何用 Mako 格式化字符串的长度吗?
相当于print "%20s%10s" % ("string 1", "string 2")?
【问题讨论】:
标签: python template-engine mako
你可以在 mako 中相当轻松地使用 python 的字符串格式化
${"%20s%10s" % ("string 1", "string 2")}
给予:
>>> from mako.template import Template
>>> Template('${"%20s%10s" % ("string 1", "string 2")}').render()
' string 1 string 2'
【讨论】: