in python, I try use templates
from string import Template
s = Template("hello $world")
print s.substitute(world="Stackoverflow")
ok, but, In the template I need concatenate a string without space, example
s = Template("a small number : $number e6")
print s.substitute(number=5)
I need a small number : 5e6
as output, without white space between 5 and e6.
Use curly braces around the pattern:
Template("a small number : ${number}e6")
Result:
>>> Template("a small number : ${number}e6").substitute(number=5)
'a small number : 5e6'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With