Python: Save A Variable As HTML File
This is probably a very simple question but I did not find any solution until now and I have been around this hours I have one HTML file 'teste.html' I Use jinja 2 to change my HTM
Solution 1:
You can just write the HTML string you have to a file with .html
extension.
For example:
htmlstring = ... # Your HTML data
with open("yourhtmlfile.html", "w") as file:
file.write(htmlstring)
Solution 2:
It sounds like you want to save your str
to a file. Saving a file in python can be done like:
with open('teste_rendered.html', 'w') as file:
file.write(html_out)
Note: The location where the file actually saves depends on how you run your python script.
Post a Comment for "Python: Save A Variable As HTML File"