如果使用python内置的字符串模板机制
from string import Templatetemplate_string = '<html><head><title>$title</title></head><body>$body</body></html>'
t = Template(template_string)
t.substitute(title='hello', body='hello world')
好处是不用安装其他的第三方的包,缺点是比较简单,不能嵌入python代码
页:
[1]