Read Text File as a String

 avatar
user_6939821
python
2 years ago
159 B
6
Indexable
#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()
Editor is loading...