Skip to content

Instantly share code, notes, and snippets.

@RASBORA
Created July 29, 2017 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RASBORA/6e72d15b9ac841f18e071b1b83b1a0bc to your computer and use it in GitHub Desktop.
Save RASBORA/6e72d15b9ac841f18e071b1b83b1a0bc to your computer and use it in GitHub Desktop.
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