Answer the question
In order to leave comments, you need to log in
How to create an html table using Python?
Greetings, the bottom line is that there is a parser that merges the necessary information into csv, but it’s inconvenient to view it on a mobile phone, and the encoding flies because the parser ignores encoding errors, I got the idea to file it all in stml, but then I blunted the stml
code:
<table style="border:2px black solid">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
Answer the question
In order to leave comments, you need to log in
>>> from jinja2 import Template
>>> template = Template("""
... <table style="border:2px black solid">
... <tr>
... {% for item in my_array %}
... <td>{{item}}</td>
... {% endfor %}
... </tr>
... </table>""")
>>> my_array = range(10)
>>> my_array
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> print(template.render(my_array=my_array))
<table style="border:2px black solid">
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
>>>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question