To write a python program for copying the contents from one file to another file.
PC Anaconda - Python 3.7
First we need to open the required file form which we need to copy the text.
Using keyword "with" to open the requied file.
Again using the with keyword to open the empty file.
The empty file is open by using 'W' which is used to write only.
The four function is used to take each line from the main file.
write() is used to write the lines of main file to the empty file or to the directed file
def fun(f_one,f_second): with open(f_one) as fp: with open(f_second,"w") as fp1: data=fp.read() fp1.write(data) f_one=input("enter the filename:1 ") f_second=input("enter the filename:2 ") fun(f_one,f_second)
Thus the program is written to copy the contents from one file to another file.