问题
Anyone know how to format the length of a string with Mako?
The equivalent of print "%20s%10s" % ("string 1", "string 2")?
回答1:
you can use python's string formatting fairly easily in mako
${"%20s%10s" % ("string 1", "string 2")}
giving:
>>> from mako.template import Template
>>> Template('${"%20s%10s" % ("string 1", "string 2")}').render()
' string 1 string 2'
来源:https://stackoverflow.com/questions/1029965/formatting-with-mako