To write a python program for copying the contents from one file to another file.
PC Anaconda - Python 3.7
Get the file name and location from the user.
Enter a new file name to create a copy of a file content.
Read the file and close te file.
Now write te content in the new file.
Print "File copied successfully" when code is completed
End of the program.
#Program to copy the contents of one file to another
#Developed by: R.SANJANA
#Register Number:23008112
fileHandle = open("Sample.txt", "r")
texts = fileHandle.readlines()
fileHandle.close()
fileHandle = open("New.txt", "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.