python有像perl那样的变量内插功能吗?
python有像perl那样的变量内插功能吗?看了本入门的书,没有看到。
作者: kingwmj 发布时间: 2011-05-15
试试这个:
QUOTE:
>>> from string import Template
>>> s = Template('$who likes $what')
>>> s.substitute(who='tim', what='kung pao')
'tim likes kung pao'
>>> s = Template('$who likes $what')
>>> s.substitute(who='tim', what='kung pao')
'tim likes kung pao'
作者: llbgurs 发布时间: 2011-05-15