Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: create_example_text.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- This script creates an example text file ('example.txt') with sample data.
- Requirements:
- - Python 3.x
- Usage:
- 1. Save this script as 'create_example_text.py'.
- 2. Run the script.
- Note: Adjust the 'text_filename' variable in the script as needed.
- """
- def create_example_text(filename):
- # Example text data (you can customize this data)
- text_data = """Hello, World!
- This is an example text file.
- Feel free to add more lines or customize the content."""
- # Write text data to the file
- with open(filename, 'w') as textfile:
- textfile.write(text_data)
- if __name__ == "__main__":
- # Set the filename for the example text file
- text_filename = 'example.txt'
- # Create the example text file in the current working directory
- create_example_text(text_filename)
- print(f"Example text file '{text_filename}' created in the current working directory.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement