Guest User

Untitled

a guest
Apr 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. def concat_files():
  2. filenames = ['file1.txt', 'file2.txt']
  3. with open('path/to/output/file', 'w') as outfile:
  4. for fname in filenames:
  5. with open(fname) as infile:
  6. for line in infile:
  7. outfile.write(line)
  8.  
  9. def concat_binary_files():
  10. with open('output_file.txt','wb') as wfd:
  11. for f in ['seg1.txt','seg2.txt','seg3.txt']:
  12. with open(f,'rb') as fd:
  13. shutil.copyfileobj(fd, wfd)
Add Comment
Please, Sign In to add comment