Python: read and write binary files









def copy(if_path, of_path):
with open(if_path, 'rb') as in_file, open(of_path, 'wb') as out_file:
while True:
chunk = in_file.read(1024)
if chunk:
out_file.write(chunk)
out_file.flush()
else:
break



No comments:

Post a Comment