How to replace a double backslash with a single backslash in python?
I'm not getting the behaviour you describe:
>>> x = "\\\\\\\\">>> print x\\\\>>> y = x.replace('\\\\', '\\')>>> print y\\
When you see '\\\\'
in your output, you're seeing twice as many slashes as there are in the string because each on is escaped. The code you wrote should work fine. Trying print
ing out the actual values, instead of only looking at how the REPL displays them.