Created
December 7, 2012 18:35
-
-
Save startakovsky/4235359 to your computer and use it in GitHub Desktop.
Make an HTML table from a List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html(tab_list([[i,i.get_sign(),d[i],d[i].get_sign()] for i in d], headers = ['element',sign,'image',sign])) | |
def tab_list(y, headers = None): | |
''' | |
Converts a list into an html table with borders. | |
''' | |
s = '<table border = 1>' | |
if headers: | |
for q in headers: | |
s = s + '<th>' + str(q) + '</th>' | |
for x in y: | |
s = s + '<tr>' | |
for q in x: | |
s = s + '<td>' + str(q) + '</td>' | |
s = s + '</tr>' | |
s = s + '</table>' | |
return s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment