World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITian's, only for AI Learners.
Download our e-book of Introduction To Python
4 (4,001 Ratings)
218 Learners
Sulochana Kamshetty
5 months ago
# a file named
"insideaiml", will be opened with the reading mode.
file = open('inisdeaaiml.txt', 'r')
file = open("insideaiml.text", "r")
print (file)
file = open("file.txt","r")
print(file.read(5))
file = open('insideaiml.txt','w')
file.write("This is the write command")
file.write("It allows us to write in a particular file")
file.close()
file = open('insideaiml.txt','a')
file.write("This will add this line")
file.close()
with open("file.txt", "w") as f:
f.write("Hello World!!!")
split() using file handling
with open("file.text", "r") as file:
data = file.readlines()
for line in data:
word = line.split()
print word