f1=open("OldFile.txt","w") //Opening of old file in write mode for writing the data
f1.write("This is old file") //Writing to the file
f1.close() //Closing of old file
f1=open("OldFile.txt","r") //Opening new file in read mode
text=f1.read() //Reading from file and storing data into another variable
f1.close() //Closing of old file
f2=open("NewFile.txt","w") //Opening new file in write mode for copying the data
f2.write(text) //Writing data means copying the of old file to new file
f2.close() //Closing of new file
f2=open("Newfile.txt","r") //Opening new file in read mode
print(f2.read()) //Reading copied data from new file
f2.close() //Closing new file
No comments:
Post a Comment