python : template var without space -


in python, try use templates

 string import template  s = template("hello $world")  print s.substitute(world="stackoverflow") 

ok, but, in template need concatenate string without space, example

 s = template("a small number : $number e6")  print s.substitute(number=5) 

i need a small number : 5e6 output, without white space between 5 , e6.

use curly braces around pattern:

template("a small number : ${number}e6") 

result:

>>> template("a small number : ${number}e6").substitute(number=5) 'a small number : 5e6' 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -