cut off \n

Tom llafba at gmx.net
Mon Jun 9 18:11:20 CEST 2003


Thanks guys!
Exactly what I needed.
Regards, Tom

Alan Kennedy wrote:

>Tom,
>
>Try this
>
>  
>
>>>>s = "This is a line with a newline at the end\n"
>>>>s.strip()
>>>>        
>>>>
>"This is a line with a newline at the end"
>  
>
>>>>t = "This is a line without a newline at the end"
>>>>t.strip()
>>>>        
>>>>
>"This is a line without a newline at the end"
>
>More info about .strip() and the related functions .lstrip() and .rstrip() can
>be found here
>
>http://www.python.org/doc/current/lib/module-string.html
>
>As well as the ".strip" function in the string module, each string instance
>supports the .strip() method as well, as can be seen above.
>
>regards,
>
>  
>





More information about the Python-list mailing list