This way, it will replace '\' with '\', so nothing change. >>> 'Hello, \\\\World'.replace('\\\\', '\\') 'Hello, \\World' >>> print 'Hello, \\\\World'.replace('\\\\', '\\') Hello, \World
On Sat, Dec 7, 2013 at 10:58 PM, Mahan Marwat <mahanmar...@gmail.com> wrote: > Why this is not working. > > >>> 'Hello, \\\\World'.replace('\\', '\\') > > To me, Python will interpret '\\\\' to '\\'. And the replace method will > replace '\\' with '\'. So, the result will be 'Hello, \World'. But it's > give me 'Hello, \\\\World'. > > The result I want form the code is 'Hello, \World'. > -- > https://mail.python.org/mailman/listinfo/python-list >
-- https://mail.python.org/mailman/listinfo/python-list