[Tutor] string conversion according to the terminal

Sander Sweers sander.sweers at gmail.com
Thu Aug 12 12:12:05 CEST 2010


On 12 August 2010 10:40, Evert Rol <evert.rol at gmail.com> wrote:
>>>> a = "my file number"
>>>> a.replace(' ', '\\ ')
> 'my\\ file\\ number'

What if a has more than 1 space between words? Then I think this would
be a safer way.

>>> print "\\ ".join("my  file  number".split())
my\ file\ number

Greets
Sander


More information about the Tutor mailing list