To write a python program for copying the contents from one file to another file.
PC Anaconda - Python 3.7
Create one text file with some contents and one empty file.
Open the file which contains the content in reading mode and naming as file1
Then open the second empty file in append mode and name it as file2
Using for loop, read the contents from file1
To append contents to file2
Now run the terminal and check whether the contents copied or not.
with open('file1.txt','r') as fp:
with open('file2.txt',"w") as fp1:
line=fp.read()
fp1.write(line)
Thus the program is written to copy the contents from one file to another file.