import struct buf = bytearray(10) struct.pack_into("