Filhandlng 4
Filhandlng 4
a. dt = f.readlines();print(dt[3])
b. dt=f.read(4) ;print(dt[3])
c. dt=f.readline(4);print(dt[3])
d. All of these
a.flush()
b. close()
c.open()
d. fflush()
a. flush()
b. close()
c. open()
d. fflush()
1. What do you mean by file? What do
you mean by file handling?
o The file refers to the collection of
in a file.
o These files saved in a specific
syntax:
o Open a text file: Syntax:<file
object> =
open(file_name,access_mode)
file object : It is just like a
variable or object
open(): It is a function with two
parameters.
file_name: It accepts a file name
r: to read a file
w: to write
a: append contents
f=open(“data.txt”,”w”)
f.close()
4. Write a statement to create a
data.txt file with the following text.