Get html output from python code

I have a dictionary and you want to create an html page where a simple html table with keys and values ​​will be drawn. How can this be done from python code?

+5
source share
5 answers
output = "<html><body><table>"
for key in your_dict:
  output += "<tr><td>%s</td><td>%s</td></tr>" % (key, your_dict[key])
output += "</table></body></html>
print output
+10
source

You can use a template engine like Jinja . A list of template engines is available here .

+2
source
+1
+1

Python, Template. , ( ) .

0

All Articles