how to delete "\n"
python at bdurham.com
python at bdurham.com
Mon Jul 12 17:53:01 EDT 2010
Thomas,
> split() also splits at other whitespace.
Doh! Corrected version follows:
print ''.join( open( 'Direct_Irr.txt' ).read().splitlines() )
Broken out:
- open(): open file
- read(): read its entire contents as one string
- splitlines(): split the contents into a list of lines
(splits lines at \n; does not include \n in split values)
- ''.join(): join list of lines with an empty char
Malcolm
More information about the Python-list
mailing list