Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
with open('modtext.txt','rb') as rp:
with open('make.bin','wb') as wp:
sumlen=0
head=sumlen.to_bytes(4,'little')
body=b''
for line in rp:
sumlen += len(line)
head += sumlen.to_bytes(4,'little')
body+=line[:-1] + b'\0'
wp.write(head)
wp.write(body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment