To write a python program for copying the contents from one file to another file.
PC Anaconda - Python 3.7
with open("text.txt","r") as f1:
data=f1.read()
with open("data.txt","w") as f2:
f2.write(data)
with open("text.txt",'w')as fp:
fp.write("Hello World")
fp.write("\nWelcome to Python")
fp.write("\nHave a Good Day")
with open("data.txt","w") as fd:
fd.write("")
with open("data.txt","r") as f2:
data1=f2.read()
print(data)
Thus the program is written to copy the contents from one file to another file.