Advertisement
dewabe

SimpleSample: Save as HTML

Aug 15th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # SimpleSample save as HTML
  3. def save_html(file_name, title, body):
  4.     try:
  5.         html = '''
  6.        <html>
  7.        <head>
  8.        <title>{title}</title>
  9.        </head>
  10.        <body>
  11.        {body}
  12.        </body>
  13.        </html>
  14.        '''.format(title=title, body=body)
  15.  
  16.         with open(file_name, "w") as f:
  17.             f.write(html)
  18.     except:
  19.         print("Error during writing")
  20.  
  21. save_html("index.html", "My WebPage", "Hello World!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement