Reputation: 3161
This question has been answered before, but my string doesn't have any extra curly brackets that would mess up the formatting, so at the moment I'm completely clueless as to why the error
Error is KeyError : content
html = """
<table class=\"ui celled compact table\" model=\"{model}\">
{theaders}
<tbody>
{content}
</tbody>
</table>
"""
html = html.format(model=model)
html = html.format(content=data)
html = html.format(theaders=theaders)
Upvotes: 4
Views: 6279
Reputation: 140168
you could do it line by line using a dictionary and passing the dict as keyword arguments using **
d=dict()
d['model']=model
d['content']=data
d['theaders']=theaders
html = html.format(**d)
Upvotes: 11
Reputation: 46849
you need to fill the values in one go:
html.format(model=model, content=data, theaders=theaders)
Upvotes: 7