shilang 发表于 2017-5-3 11:54:40

如果使用python内置的字符串模板机制

from string import Template
template_string = '<html><head><title>$title</title></head><body>$body</body></html>'
t = Template(template_string)
t.substitute(title='hello', body='hello world')


  好处是不用安装其他的第三方的包,缺点是比较简单,不能嵌入python代码
页: [1]
查看完整版本: 如果使用python内置的字符串模板机制