Open and read files in python

 # first argument in the file name which is going to open

#  and second the mode of the file in which the file is going to open


= open("22_reading_file.txt""rt")
#for reading the line from file
print(f.readlines())
#for reading the file as a list
# print(f.readlines())
# file_content = f.read()
# file_content = f.read(10)# for reading the limited character from the file
# print(file_content)
# for reading line by line content from the file
# for line in f:
#   print(line,end="")
f.close()



Comments