File Handling Problem

Tim Golden mail at timgolden.me.uk
Fri Sep 4 17:39:37 CEST 2009


Rami Chowdhury wrote:
>> f = open("myfile.txt", "r")
>> list_one = f.read().splitlines()
>> f.close()
> 
> Or use f.readlines(), which would do the same thing IIRC?

No: readlines () retains the "\n"s; splitlines () loses them

TJG



More information about the Python-list mailing list