[Python] How to write and save html file in python?

Discussão em 'Python' iniciado por Stack, Maio 26, 2025.

  1. Stack

    Stack Membro Participativo

    This is what I know about writing to an HTML file and saving it:

    html_file = open("filename","w")
    html_file.write()
    html_file.close()


    But how do I save to the file if I want to write a really long codes like this:

    1 <table border=1>
    2 <tr>
    3 <th>Number</th>
    4 <th>Square</th>
    5 </tr>
    6 <indent>
    7 <% for i in range(10): %>
    8 <tr>
    9 <td><%= i %></td>
    10 <td><%= i**2 %></td>
    11 </tr>
    12 </indent>
    13 </table>

    Continue reading...

Compartilhe esta Página