Splitting lines in a file

Simon Foster simon at uggs.demon.co.uk
Sun Jul 7 18:37:37 EDT 2002


On 7 Jul 2002 22:30:55 GMT, William Park
<opengeometry at NOSPAM.yahoo.ca> wrote:

>'1\n2\n3\n'.split() works as follows:
>    1\n2\n3\n -> 1\n2\n3 -> 1 \n 2 \n 3 -> 1 2 3
>
>'1\n2\n3\n'.split('\n') works as follows:
>    1\n2\n3\n -> 1 \n 2 \n 3 \n -> 1 2 3 ''
>where the last '\n' separates '3' and '' (null).
>
>-- 
>William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
>8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin

Still seems odd!
--
Simon Foster
Cheltenham
England



More information about the Python-list mailing list