4 type of read file using python.

                      Welcome to file reader 



This is file reader using python.







#
# copyright by pyprojectlab
#

# All text print
file_open=open("file_path","r")
print(file_open.read())
file_open.close()

# Print line or lines which you want
file_open=open("file_path","r")
print(file_open.readline())
print(file_open.readline())
print(file_open.readline()) #or more you need
file_open.close()

# Print all lines
file_open=open("file_path","r")
print(file_open.readlines())
file_open.close()

# Print all line and count
file_open=open("file_path","r")
print("Lines This is text")
for x,i in enumerate(file_open):
print(f" {x} ",i)
file_open.close()

Comments

Popular posts from this blog

Screen Recording using python.

wallpaper changer.

Find any color from image using python