Formatting with mako

坚强是说给别人听的谎言 提交于 2019-12-24 03:24:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!