In python, what is the most elegant way to generate HTML documents. I currently manually append all of the tags to a giant string, and write that to a file. Is there a mor
Yes, you are looking for file .writelines
A sequence is generally a list or array. So put all your lines into a list or array. And toss them to the function below.
Make sure to remove any new line constants from your strings just to be safe
Python Documentation ( search for file.writelines )
file.writelines(sequence) Write a sequence of strings to the file. The sequence can be any iterable object producing strings, typically a list of strings. There is no return value. (The name is intended to match readlines(); writelines() does not add line separators.)