World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Download our e-book of Introduction To Python
4.5 (1,292 Ratings)
559 Learners
Sulochana Kamshetty
a year 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