Feb-13-2017, 08:04 PM
Simple file reading? I'm not sure if this is better than csv, or if just seeing the general way people handle resources is more important...
>>> text = ''' ... hello, my name is ... wait, who am i? ... ''' >>> text = text.split('\n') >>> with open('saved_data.txt', 'w') as f: ... for line in text: ... print(line, file=f) ... >>> text = "spam" >>> # now we don't have any reference to the original text floating around ... >>> with open('saved_data.txt') as f: ... for line in f: ... print(line.rstrip()) ... hello, my name is wait, who am i? >>>