Stupid "\" question
glandrum at my-deja.com
Fri Nov 17 15:33:23 CET 2000
In article <4O9R5.709$n9.126221 at newsread2.prod.itd.earthlink.net>,
"Gene C" <gchiaramonte at yahoo.com> wrote:
> If I get an input string from a user or file like this: "a\b\c"
> How do I convert it to this: "a\\b\\c"
> Desired behavior:
> >>> s = "a\b\c"
> >>> t = doit(s) # ???
> >>> t
I'm not sure that I completely understand the question.
The "double backslash" representation is standard for a string
which contains backslashes.
So, if you enter the string using the r'' notation:
>>> s = r'a\b\c'
which is, I think, what you want.
The same thing happens if you read the string from the user:
>>> s = raw_input()
Is this approaching an answer to your question?
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list