representing a literal single slash
Jonathan Claggett
hellen at claggetts.net
Sun Sep 15 20:20:38 EDT 2002
"dsavitsk" <dsavitsk at e-coli.net> wrote in message
> > > str = str.replace('\\', '\') # broken
> >
> > in the above you are replacing a single slash with, well, with nothing.
> try
> > >>> str = str.replace('\\\\', '\\') # [not] broken
> >
> > -d
>
> you might also want to rename that variable. else the str() function will
> be a problem.
Thanks, that works. I knew it was an easy one :-)
BTW, my code now looks like this:
mystr = mystr.replace(r'\\', '\\') # replace two slashes with on
More information about the Python-list
mailing list