With Statement in File.py

#with statement is shortcut for open and colse a file
#1st read 10 character
with open("input.txt", "r") as f :
print("1st :: ", f.read(10))

#2nd read all file
with open("input.txt", "r") as f :
print("\n2nd :: ", f.read())

#write something in file
with open("input.txt", "a") as f :
f.write("\nI am from Vorisal")

Comments