Advertisement
Python253

create_example_html

Mar 11th, 2024
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Filename: create_example_html.py
  4. # Version: 1.0.0
  5. # Author: Jeoi Reqi
  6.  
  7. """
  8. Description:
  9. This script creates an example HTML file ('example.html') with sample content.
  10.  
  11. Requirements:
  12. - Python 3.x
  13.  
  14. Usage:
  15. 1. Save this script as 'create_example_html.py'.
  16. 2. Run the script.
  17.  
  18. Note: Adjust the 'html_filename' variable in the script as needed.
  19. """
  20.  
  21. def create_example_html(html_filename):
  22.     html_content = """
  23.    <!DOCTYPE html>
  24.    <html>
  25.        <head>
  26.            <title>Example HTML</title>
  27.        </head>
  28.        <body>
  29.            <h1>Hello, World!</h1>
  30.            <p>This is an example HTML file.</p>
  31.            <p>Feel free to customize the content.</p>
  32.        </body>
  33.    </html>
  34.    """
  35.  
  36.     with open(html_filename, 'w') as htmlfile:
  37.         htmlfile.write(html_content)
  38.  
  39. if __name__ == "__main__":
  40.     # Set the filename for the example HTML file
  41.     html_filename = 'example.html'
  42.    
  43.     # Create the example HTML file in the current working directory
  44.     create_example_html(html_filename)
  45.  
  46.     print(f"Example HTML file '{html_filename}' created in the current working directory.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement