template systems (in this case using HTML): : Template « String « Python Tutorial






from string import Template


template = '''<html> 
<head><title>%(title)s</title></head> 
<body> 
<h1>%(title)s</h1> 
<paragraph>%(text)s</paragraph> 
</body>'''


data = {'title': 'My Home Page', 'text': 'Welcome to my home page!'}
print template % data








5.36.Template
5.36.1.template strings
5.36.2.Interpolating Variables Inside Strings
5.36.3.If the replacement field is part of a word, the name must be enclosed in braces
5.36.4.In order to insert a dollar sign, use $$
5.36.5.you can supply the value-name pairs in a dictionary
5.36.6.template systems (in this case using HTML):