To write a python program for copying the contents from one file to another file.
PC Anaconda - Python 3.7
get the file name to create user
give a new file name to create a copy of a file content
read the file and close the file
now the content in the new file
when done print"File Copied Successfully"
end the program
Program to copy the file.
#Developed by: Harini.S
#RegisterNumber:23004240
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.