import os tree = {} html_tree = '''' with open('out.html', 'w') as file: file.write(html_tree)