题
任何人都知道如何用Mako格式化字符串的长度?
相当于 print"%20s%10s" %(" string 1"," string 2")?
解决方案
你可以在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'
不隶属于 StackOverflow