Is It Bug?

Iuri iurisilvio at gmail.com
Sat Dec 7 20:04:13 EST 2013


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 <mahanmarwat at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131207/905d1382/attachment.html>


More information about the Python-list mailing list