[Tutor] string conversion according to the terminal

Evert Rol evert.rol at gmail.com
Thu Aug 12 10:40:39 CEST 2010

> Hey- suppose we have a file name-"my file number"
> if we want to execute it into the terminal it would be like - my\ file\ number
> so wondering is there any one in the python that change the enter string into the terminal string one-
> like if user enter the file name with path- "my file number". i want to automatically convert it into "my\ file\ number"
> Plz help me out in this.

>>> a = "my file number"
>>> a.replace(' ', '\\ ')
'my\\ file\\ number'
>>> print a.replace(' ', '\\ ')
my\ file\ number

More information about the Tutor mailing list