Question

Quelqu'un sait comment formater la longueur d'une chaîne avec Mako?

L'équivalent de print ""% 20s% 10s " % ("Chaîne 1", "Chaîne 2") ?

Était-ce utile?

La solution

vous pouvez utiliser le formatage de chaîne de python assez facilement dans mako

${"%20s%10s" % ("string 1", "string 2")}

donnant:

>>> from mako.template import Template
>>> Template('${"%20s%10s" % ("string 1", "string 2")}').render()
'            string 1  string 2'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top