joh*_*nix 2 python template-engine mako
谁知道如何用Mako格式化字符串的长度?
相当于打印"%20s%10s"%("字符串1","字符串2")?
你可以在mako中相当容易地使用python的字符串格式
${"%20s%10s" % ("string 1", "string 2")}
Run Code Online (Sandbox Code Playgroud)
赠送:
>>> from mako.template import Template
>>> Template('${"%20s%10s" % ("string 1", "string 2")}').render()
' string 1 string 2'
Run Code Online (Sandbox Code Playgroud)