Python 用mako格式化
有人知道如何用Mako格式化字符串的长度吗Python 用mako格式化,python,template-engine,mako,Python,Template Engine,Mako,有人知道如何用Mako格式化字符串的长度吗 相当于打印“%20s%10s”(“字符串1”、“字符串2”)?您可以在mako中相当轻松地使用python的字符串格式 ${"%20s%10s" % ("string 1", "string 2")} 给予: >>> from mako.template import Template >>> Template('${"%20s%10s" % ("string 1", "string 2")}').render()
相当于打印“%20s%10s”(“字符串1”、“字符串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'