Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: create_example_bin.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- This script creates an example binary file ('example.bin') containing the binary data 'Hello, World!'.
- Requirements:
- - Python 3.x
- Usage:
- 1. Save this script as 'create_example_bin.py'.
- 2. Run the script.
- Note: Adjust the 'example_filename' variable in the script as needed.
- """
- def create_example_bin(filename):
- # Example binary data (Hello, World!)
- binary_data = bytes([0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x2C, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x21])
- # Write binary data to the file
- with open(filename, 'wb') as binfile:
- binfile.write(binary_data)
- if __name__ == "__main__":
- # Set the filename for the example binary file
- example_filename = 'example.bin'
- # Create the example binary file in the current working directory
- create_example_bin(example_filename)
- print(f"Example binary file '{example_filename}' created in the current working directory.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement