0

I have the following output list from python list.

['N3132-a', '172.20.138.18', '192.168.193.15/24', 'N3132-a.td.com ', 'N3K-C3132Q-40GX', 'FOC2116XCFV', 'NXOS: version 7.0(3)I4(6)']

['N56k-a', '10.249.98.11', '192.168.173.16/24', 'N56k-a.td.com ', 'N5K-C56128P', 'FOC2187FGHJ', 'kickstart: version 7.1(4)N1(1)']

['N3164-b', '172.16.48.14', '192.168.130.12/24', 'N3164-b.td.com ', 'N3K-C3164Q-40GE', 'FDO26HJKL2', 'NXOS: version 7.0(3)I4(6)']

['5596-a', '10.250.98.20', '192.168.170.25/24', '5596-a.td.com ', 'N5K-C5596UP', 'FOX2398HGF', 'kickstart: version 7.1(4)N1(1)']

['N3064-B', '172.17.47.20', '192.168.130.25/24', 'N3064-B.td.com ', 'N3K-C3064PQ-10GX', 'FOC193FGHJNM', 'NXOS: version 7.0(3)I4(6)']

I need to loop this data in html and print this in html table .

I have the following html code which works but creating each table instead of one table

Manual input work like this

<HTML>
<head>
<title>Data</title>

</head>
<body>

    <h1><marquee>Welcome To The Page</marquee></h1>
    <h1>Data :</h1>

    <table  border="4" align="center">


     <th style="background-color:yellow !important;"><h2><br>dc</h2></th>
     <th style="background-color:yellow !important;"><h2><br>proxi</h2></th>
     <th style="background-color:yellow!important;"><h2><br>id</h2></th>
     <th style="background-color:yellow !important;"><h2><br>email</h2></th>
     <th style="background-color:yellow!important;"><h2><br>face-1</h2></th>
     <th style="background-color:yellow!important;"><h2><br>face-2</h2></th>
     <th style="background-color:yellow!important;"><h2><br>face-3</h2></th>
     <tr><td>N3132-a</td><td>172.16.139.15</td><td>192.168.195.15/24</td><td>N3132-a.td.com </td><td>N3K-C3132Q-40GX</td><td>FOC2116</td><td>NXOS: version 7.0(3)I4(6)</td></tr><tr><td>N56k-a</td><td>10.249.99.11</td><td>192.168.175.11/24</td><td>N56k-a.td.com </td><td>N5K-C56128P</td><td>FOC2109L</td><td>kickstart: version 7.1(4)N1(1)</td></tr>

</table>
</body>
</HTML>

need to loop that input data in python and print that html file instead of manual data in html table.

4

1 Answer 1

0

You can put whole html in python variable and for list output , you can do like this:

l=['N3132-a', '172.20.138.18', '192.168.193.15/24', 'N3132-a.td.com ', 'N3K- 
C3132Q-40GX', 'FOC2116XCFV', 'NXOS: version 7.0(3)I4(6)']
for item in l:
   print('<td>'+item+'</td>')
Sign up to request clarification or add additional context in comments.

3 Comments

how do i add that to html
You can edit you code file writing in file like [stackoverflow.com/questions/43064938/…
<td>d</td><td>N</td><td>3</td><td>1</td><td>-</td><td>3</td><td>2</td><td>-</td><td>a</td> instead of <td>N3132-a</td>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.