Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def concat_files():
- filenames = ['file1.txt', 'file2.txt']
- with open('path/to/output/file', 'w') as outfile:
- for fname in filenames:
- with open(fname) as infile:
- for line in infile:
- outfile.write(line)
- def concat_binary_files():
- with open('output_file.txt','wb') as wfd:
- for f in ['seg1.txt','seg2.txt','seg3.txt']:
- with open(f,'rb') as fd:
- shutil.copyfileobj(fd, wfd)
Add Comment
Please, Sign In to add comment