File Copy Function

  • Share this:

Code introduction


This function is used to copy all the contents of one file into another.


Technology Stack : Built-in library

Code Type : File operation

Code Difficulty : Intermediate


                
                    
def zip_file(input_file, output_file):
    with open(input_file, 'rb') as f_in:
        with open(output_file, 'wb') as f_out:
            while True:
                chunk = f_in.read(1024)
                if not chunk:
                    break
                f_out.write(chunk)
    return output_file