Read Text File as a String

 avatar
user_6939821
python
a year ago
159 B
2
Indexable
Never
#open text file in read mode
text_file = open("D:/data.txt", "r")
 
#read whole file to a string
data = text_file.read()
 
#close file
text_file.close()