Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78269
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <prvs=3379a0b56=jeanmichel@sequans.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.105 |
| X-Spam-Level | * |
| X-Spam-Evidence | '*H*': 0.79; '*S*': 0.00; 'wednesday,': 0.07; 'subject:skip:a 10': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '2.7': 0.14; 'template': 0.14; "'w')": 0.16; 'examples': 0.20; 'import': 0.22; 'cc:addr:gmail.com': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'file': 0.32; 'figure': 0.32; '-----': 0.33; 'subject:the': 0.34; 'display': 0.35; "didn't": 0.36; 'subject:?': 0.36; 'email addr:python.org': 0.37; 'thank': 0.38; 'subject:': 0.39; 'how': 0.40; 'you.': 0.62; 'information': 0.63; 're:': 0.63; 'received:194': 0.64; 'email name:python-list': 0.65; 'to:addr:gmail.com': 0.65; 'notice:': 0.67; 'person,': 0.68; 'skip:m 50': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'medium.': 0.91 |
| X-IronPort-AV | E=Sophos;i="5.04,587,1406584800"; d="scan'208";a="3361827" |
| Date | Wed, 24 Sep 2014 11:27:24 +0200 (CEST) |
| From | Jean-Michel Pichavant <jeanmichel@sequans.com> |
| To | luofeiyu <elearn2014@gmail.com> |
| In-Reply-To | <5421FCF1.2060409@gmail.com> |
| Subject | Re: how to write a html to automatically display the dictionary? |
| MIME-Version | 1.0 |
| X-Mailer | Zimbra 7.2.7_GA_2942 (ZimbraWebClient - GC35 (Linux)/7.2.7_GA_2942) |
| Content-Type | text/plain; charset="utf-8" |
| Content-Transfer-Encoding | base64 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14301.1411550852.18130.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1411550852 news.xs4all.nl 2892 [2001:888:2000:d::a6]:54195 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:78269 |
Show key headers only | View raw
----- Original Message -----
> From: "luofeiyu" <elearn2014@gmail.com>
> To: "Joel Goldstick" <joel.goldstick@gmail.com>, python-list@python.org
> Sent: Wednesday, 24 September, 2014 1:06:25 AM
> Subject: Re: how to write a html to automatically display the dictionary?
>
>
> how can i create the proper html file with Jinjia 2 or other temple?
>
template :)
I'm surprised you didn't figure it out by looking at jinja2 examples in their documentation.
python 2.7 :
from jinja2 import Template
template = Template('''
<table border=1>
<tr>{% for k in x.keys()%}<th>{{k}}</th>{%endfor%}</tr>
<tr>{% for k in x.values()%}<td>{{k}}</td>{%endfor%}</tr>
</table>''')
with open('foo.html', 'w') as myFile:
myFile.write(template.render(x={'f1':1,'f2':2,'f3':3}))
Regards,
JM
-- IMPORTANT NOTICE:
The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: how to write a html to automatically display the dictionary? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-09-24 11:27 +0200
csiph-web