File handeling¶
In [ ]:
# to open a file use function open:
f= open('file_name', 'mode')
file handeling modes:¶
r: open existing file (read only)
w: open existing file to write (override all previous data in the file)
a: open existing file to append information
r+: To read and write data into the file. (override all previous data)
w+: To write and read data. (override all previous data)
a+: To append and read.
In [ ]:
file = open('example.txt', 'r')
for line in file:
print (line)