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.
Now create a new file in which we want to paste the content using write access mode.
The content in the original file will be copied in the new file.
End the program.
Developed by: LOKESH RAHUL V V
Register no: 22004702
print("Enter the Name of Source File: ")
sFile = input()
print("Enter the Name of Target File: ")
tFile = input()
fileHandle = open(sFile, "r")
texts = fileHandle.readlines()
fileHandle.close()
fileHandle = open(tFile, "w")
for s in texts:
fileHandle.write(s)
fileHandle.close()
print("\nFile Copied Successfully!")
Thus the program is written to copy the contents from one file to another file.