python - Reading text file to array -


i trying read file array, current implementation returning first line of .txt file

import re def gettext(filename): print('opening file...')  text_file= open(filename,'r') lines = text_file.readlines() #each line appended list  text_file:     one_string= text_file.read().replace('\n', '') print(one_string) 

my question is: how read text file array?

instead of reading whole file line @ atime why not read in 1 go , split based on full stops (periods) in order sentences... ie:

text_file= open(filename,'r') data=text_file.read() listofsentences = data.split(".") 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -