File read, write, & append

#this is used to write sth in a file but previous content will be delete

f=open("harish", "w")
f.write("harish is good boy ")
f.close()

#this is used to add sth in a file at end but in this previous content will not delete

f=open("harish", "a")
f.write("harish is goldenba\n ")
f.close()

#in this we can find out how many charecters we add in file

f=open("harish", "a")
a=f.write("harish is goldenba\n ")
print(a)
f.close()

#this is used to read and write both

f=open("harish", "r+")
print(f.read())
f.write("well dude")

Comments

Popular posts from this blog

Steps taken by a compiler to execute a C program

Tokens in C

Variables and Data Types in C