Mega Code Archive

 
Categories / Python Tutorial / String
 

Template systems (in this case using HTML)

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