File read right and append function and seek tell function -16

 


#NORMAL UPIA OPENAND READ

k=open("munna2.tex","r+")
k.write("Munna is a good boy\n")
k.write("Munna is a good boy 2")
k=open("munna2.tex","r+")
print(k.read())
k.close()

#WITH DIYE OPEN AND READ

with open("munna2.tex" ,"r+") as f:
f.write("My Name Is Munna")
with open("munna2.tex", "r+") as f:
print(f.read())

#ABAR WITH DIYE OPEN AND READ

with open("munna2.tex" ,"r+") as f:
f.write("\nI am a good boy")
with open("munna2.tex", "r+") as f:
print(f.read())

#WITH DIYE APPEND
with open("munna2.tex" ,"a") as f:
f.write("\n append it")
with open("munna2.tex", "r+") as f:
print(f.read())

#SEEK AND TELL FUNCTION
with open("munna.txt" ,"r+") as f:
print(f.readline())
print(f.tell())
f.seek(0) #KOTO NO INDEXA POINTER ACHE TY BOLE
print(f.readline())
f.seek(2)
print(f.readline()) #POINTER AR DEFAULT VALUE RESET KORE ICCHA MOTO VALUE DEI

















Comments

Popular posts from this blog

D WEB LINK