How to merge two binary files into one?

could ildg could.net at gmail.com
Tue Apr 5 03:33:29 EDT 2005


I'm so glad that this this problem has so many recipes.

On Apr 5, 2005 1:57 PM, Andrew Dalke <dalke at dalkescientific.com> wrote:
> Grant Edwards wrote:
> > For large files, something like this is probably a better idea:
> 
> Or with the little-used shutil module, and keeping your
> nomenclature and block size of 65536
> 
> import shutil
> fout = file('C', 'wb')
> for n in ['A', 'B']:
>   fin = file(n, 'rb')
>   shutil.copyfileobj(fin, fout, 65536)
>   fin.close()
> fout.close()
> 
>                                 Andrew
>                                 dalke at dalkescientific.com
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
鹦鹉聪明绝顶、搞笑之极,是人类的好朋友。
直到有一天,我才发觉,我是鹦鹉。
我是翻墙的鹦鹉。



More information about the Python-list mailing list