Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78227
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx10.iad.POSTED!not-for-mail |
|---|---|
| Message-ID | <5421A594.8030604@tobiah.org> (permalink) |
| From | Tobiah <toby@tobiah.org> |
| User-Agent | Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.python |
| Subject | Re: how to write a html to automatically display the dictionary? |
| References | <mailman.14262.1411481932.18130.python-list@python.org> |
| In-Reply-To | <mailman.14262.1411481932.18130.python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Lines | 43 |
| X-Complaints-To | abuse@teranews.com |
| NNTP-Posting-Date | Tue, 23 Sep 2014 16:53:41 UTC |
| Organization | TeraNews.com |
| Date | Tue, 23 Sep 2014 09:53:40 -0700 |
| X-Received-Bytes | 1403 |
| X-Received-Body-CRC | 3528077181 |
| Xref | csiph.com comp.lang.python:78227 |
Show key headers only | View raw
On 09/23/2014 07:18 AM, luofeiyu wrote:
> x={'f1':1,'f2':2,'f3':3}
> how can i create the following html file automatically with python to display x ?
>
> <table border=1>
> <tr>
> <td>
> f1
> </td>
> <td>
> f2
> </td>
> <td>
> f3
> </td>
> </tr>
> <td>
> 1
> </td>
> <td>
> 2
> </td>
> <td>
> 3
> </td>
> <tr>
> </tr>
> </table>
def tablefy(values):
print "<tr>"
for value in values:
print "<td>%s</td>" % value
print "</tr>"
x = {'f1': 1,'f2': 2,'f3': 3}
print "<table border=1>"
tablefy(x.keys())
tablefy(x.values())
print "</table>"
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to write a html to automatically display the dictionary? luofeiyu <elearn2014@gmail.com> - 2014-09-23 22:18 +0800
Re: how to write a html to automatically display the dictionary? Tobiah <toby@tobiah.org> - 2014-09-23 09:53 -0700
Re: how to write a html to automatically display the dictionary? Denis McMahon <denismfmcmahon@gmail.com> - 2014-09-23 20:20 +0000
Re: how to write a html to automatically display the dictionary? John Gordon <gordon@panix.com> - 2014-09-23 17:34 +0000
Re: how to write a html to automatically display the dictionary? Denis McMahon <denismfmcmahon@gmail.com> - 2014-09-23 20:53 +0000
Re: how to write a html to automatically display the dictionary? Ned Batchelder <ned@nedbatchelder.com> - 2014-09-23 19:55 -0400
csiph-web