To write a python program for copying the contents from one file to another file.
PC Anaconda - Python 3.7
Use open function to open the file in which we want to copy from and access it in read mode.
Read the file and store in a variable.
Now create a new file in which we want to paste the content using write access mode.
Use write function to copy the read file that has been stored in the variable.
The content in the original file will be copied in the new file.
End the program.
#To write a program for copying the contents from one file to another file.
#Developed by: Shaik Shoaib Nawaz
#RegisterNumber: 22005600
with open("Myfile.txt","r") as fp:
x = fp.read()
with open("Myfile2.txt","w") as fp1:
fp1.write(x)
Thus the program is written to copy the contents from one file to another file.