import struct import sys # We build the content of the file in a byte string first # This lets us calculate the length for the header at the end data = b'' data += b"A"*32 # Merchant ID data += b"B"*32 # Customer ID data += struct.pack("