Showing posts with label making duplicate file in python. Show all posts
Showing posts with label making duplicate file in python. Show all posts

Thursday, 12 October 2017

Copying content of one file to another file



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



Python Program to find Fabonacci

fabtab={} def fabonacci(n):     fabtab[0]=0     fabtab[1]=1     for i in range(2,n+1):         fabtab[i]=fabtab[i-1]+fabtab[i-2]         ...