representing a literal single slash

Jonathan Claggett hellen at claggetts.net
Sat Sep 14 22:28:02 EDT 2002


Here is an easy question (I'm hoping).

I'm trying to process a string so that all doubled up backslashes (\\)
are replaced with a single backslash (\).

The obvious approach doesn't work since a single backslash can't end a
string:

str = str.replace('\\', '\') # broken

So, how does one represent a literal single slash? unicode or hex
values perhaps?

Thanks,

Jonathan



More information about the Python-list mailing list