title: Python open html files but do not know how to save as with a different name
body: <p>Im trying to open a template, modified and save it with a different name. I have done it with csv but never with html.</p>
  
  <pre><code>import csv
  import pandas as pd
  with open('filename.csv', 'r') as infile, open('new_filename.csv'), 'w') as outfile:
          stripped = (line.strip() for line in infile)
          lines = (line.split(";") for line in stripped if line)
          writer = csv.writer(outfile)
          writer.writerows(lines)
  </code></pre>
  
  <p>My script in HTML is:</p>
  
  <pre><code>f = open('filename.html','wb')
  
  message= """&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;&lt;p&gt;My code&lt;/p&gt;&lt;/body&gt;
  &lt;/html&gt;"""
  
  f.write(message)
  f.close()
  </code></pre>
  
  <p>It can I put in the last code save outfile as? or is there another better and useful way to do it? 
  Thank you for your help and advice. </p>