Different Modes in file handling

f=open("file1.txt","w")
while(True):
  t=input("t: ")
  if(t== "@"):
    print("The End")
    break
  else:
    f.write(t)
    f.write("\n")
f.close()
f=open("file1.txt","r")
x=f.read ()
print (x)
f = open(" file1.txt","a")
while(True):
  t= input("t:")
  if(t == "@"):
     print("The End")
     break
  else:
     f.write(t)
     f.write("\n")
f.close()

f=open("file2.txt","x")
while(True):
  t=input(":")
  if(t=="@"):
    print ("The End")
    break
  else:
    f.write (t)
    f.write("\n")
f.close ()

Popular posts from this blog

Update

Types of arguments in python

Select