I'm having trouble writing binary data out to a file.
My end goal is to add a chunk to a PNG file; which has a format of: length (4 bytes), type (4 bytes), data (lots of bytes), crc32 (4 bytes). Collecting each of these pieces is not a problem, but when the chunk is inserted, each item gets a "\n" (0x0a) appended to it, and the numeric items (length, crc32) get written as strings instead of just their numeric values.
f = open('output.png', 'wb')
f.write(prependBytes)
f.write(fileLength)
f.write(pngChunk)
f.write(fileData)
f.write(fileCRC32)
f.write(appendBytes)
f.close()
How do I get the numeric values written to file as just their number, and how do I get Python to not append a \n to each item it writes?