How to read entire text file in Python?


PHOTO EMBED

Wed May 27 2020 17:25:40 GMT+0000 (UTC)

Saved by @hamzaafridi #python

# Open a file: file
file = open('my_text_file',mode='r')
 
# read all lines at once
all_of_it = file.read()
 
# close the file
file.close()
content_copyCOPY

https://cmdlinetips.com/2018/01/how-to-read-entire-text-file-in-python/