Any algorithm to preserve whitespaces?

Peter Otten __peter__ at web.de
Wed Jan 23 04:46:50 EST 2013


Santosh Kumar wrote:

> I am in a problem.
> 
>     words = line.split(' ')
> 
> preserve whitespaces but the problem is it writes an additional line
> after every line.

Strip off the newline at the end of the line with:

line = line.rstrip("\n")
words = line.split(" ")






More information about the Python-list mailing list