Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: test_0bin_1bin.py
- # Author: Jeoi Reqi
- """
- This Python script generates test data and creates 0.bin and 1.bin files in the current working directory.
- Requirements:
- - Python 3
- Description:
- The script creates two binary files, 0.bin and 1.bin, in the current working directory.
- It encodes test content into these files using UTF-8 encoding.
- The purpose is to provide sample input files for testing a binary file decoding script.
- The generated files contain simple text messages for demonstration purposes.
- Usage:
- Run the script using a Python 3 interpreter. The generated 0.bin and 1.bin files will be saved in the same directory as the script.
- """
- def write_binary_file(file_name, content):
- with open(file_name, 'wb') as binary_file:
- binary_file.write(content.encode('utf-8'))
- if __name__ == "__main__":
- # Test content for 0.bin and 1.bin
- test_content_0 = "This is a test for 0.bin file."
- test_content_1 = "And this is a test for 1.bin file."
- # Write to 0.bin
- write_binary_file('0.bin', test_content_0)
- print(f'Test content for 0.bin written to 0.bin')
- # Write to 1.bin
- write_binary_file('1.bin', test_content_1)
- print(f'Test content for 1.bin written to 1.bin')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement