Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37434

Re: Any algorithm to preserve whitespaces?

From Peter Otten <__peter__@web.de>
Subject Re: Any algorithm to preserve whitespaces?
Date 2013-01-23 10:46 +0100
Organization None
References <CAE7MaQZyvwOvD6ggMDZ4+b=r1PsKuYX+VZThEpKvxBbfJJCK3g@mail.gmail.com> <50FAEE23.5030107@lightbird.net> <CAE7MaQb2-qQXuAJ4jK6RB+fOPO0ZjK6_gEuigqP_FOn0=Sv29g@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.875.1358934417.2939.python-list@python.org> (permalink)

Show all headers | View raw


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(" ")


Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Any algorithm to preserve whitespaces? Peter Otten <__peter__@web.de> - 2013-01-23 10:46 +0100

csiph-web