I am trying to read a file into an array, my current implementation is only returning the first line of the .txt file
import re def GetText(filename): print('Opening file...') text_file= open(filename,'r') lines = text_file.readlines() #each line is appended to a list with text_file: one_string= text_file.read().replace('\n', '') print(one_string) My question is: How do I read a text file to an array?
readlines()and reaching the end of file , you would get anything other than empty string fromtext_file.read()?lower_case_with_underscoresstyle.