Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get html output from python code

Tags:

python

html

I have dictionary and would like to produce html page where will be drawn simple html table with keys and values. How it can be done from python code?

like image 786
yart Avatar asked Dec 23 '09 16:12

yart


3 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
like image 196
rui Avatar answered Oct 15 '22 16:10

rui


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

like image 2
jbochi Avatar answered Oct 15 '22 15:10

jbochi


You maybe interested by markup see http://markup.sourceforge.net/

like image 1
luc Avatar answered Oct 15 '22 16:10

luc