----- Original Message -----
> From: "luofeiyu" <[email protected]>
> To: "Joel Goldstick" <[email protected]>, [email protected]
> 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.
--
https://mail.python.org/mailman/listinfo/python-list