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


Groups > comp.lang.python > #37434 > unrolled thread

Re: Any algorithm to preserve whitespaces?

Started byPeter Otten <__peter__@web.de>
First post2013-01-23 10:46 +0100
Last post2013-01-23 10:46 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#37434 — Re: Any algorithm to preserve whitespaces?

FromPeter Otten <__peter__@web.de>
Date2013-01-23 10:46 +0100
SubjectRe: Any algorithm to preserve whitespaces?
Message-ID<mailman.875.1358934417.2939.python-list@python.org>
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(" ")


[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web