from yattag import Doc doc, tag, text = Doc().tagtext() with tag('html'): with tag('body'): with tag('h1'): text('Hello World') print(doc.getvalue())
from yattag import Doc doc, tag, text = Doc().tagtext() with tag('html'): with tag('body'): with tag('table'): with tag('tr'): with tag('th'): text('ID') with tag('th'): text('Name') with tag('tr'): with tag('td'): text('1') with tag('td'): text('John') with tag('tr'): with tag('td'): text('2') with tag('td'): text('Mary') print(doc.getvalue())This example shows how to use yattag to create an HTML table. The `with tag('table'):` statement creates the table, and the `with tag('tr'):` statements create the table rows. The `with tag('td'):` statements create the table cells. Library: yattag.