\r for newline in readlines function
Peter Hansen
peter at engcorp.com
Fri Sep 19 13:41:51 EDT 2003
Bob Gailer wrote:
>
> At 10:37 AM 9/19/2003, Leeds, Mark wrote:
>
> > I did more investigation into my previous problem
> > and what happens is that my text file has \r for representing
> > a new line instead
> > of a \n. is there a way to tell the readlines
> > function that the symbol for a newline is \r rather
> > than \n ? right now the readlines function reads
> > the\r as another item in the list and just puts
> > everything into one big list because it
> > doesn't find any new line characters.
> > thanks. i'm really stuck because
> > i can't read my data right now.
>
> bigList = foo.readlines()
> niceList = bigList.split('\r')
I think Bob means foo.read() instead, since otherwise the
result is a list which won't respond to the .split() call well.
-Peter
More information about the Python-list
mailing list