在 python 中,我尝试使用模板
from string import Template
s = Template("hello $world")
print s.substitute(world="Stackoverflow")
好的,但是,在模板中我需要连接一个没有空格的字符串,例如
s = Template("a small number : $number e6")
print s.substitute(number=5)
我需要a small number : 5e6
作为输出,在 5 和 e6 之间没有空格。