list to string
tdelaney at avaya.com
Wed Feb 28 03:00:56 CET 2001
> > text = string.join(f.readlines(), '\n')
> f.readlines() leaves the line terminator at the end of each of its
> lines, so the first expression will double the line terminators
> (except at the end of the last line).
I'm willing to believe it - I don't use readlines(), so I was going off the
Read until EOF using readline() and return a list containing the lines thus
read. If the optional sizehint argument is present, instead of reading up to
EOF, whole lines totalling approximately sizehint bytes (possibly after
rounding up to an internal buffer size) are read.
Doesn't mention whether the end-of-line characters are left or not.
So, that should be ...
text = string.join(f.readlines(), '')
More information about the Python-list