Re: str.replace() when str contains \

2022-10-29 Thread MRAB
On 2022-10-29 19:21, Bernard LEDRU wrote: Hello, https://docs.python.org/3/library/stdtypes.html#string-methods str.replace(old, new[, count])¶ Return a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurr

Re: str.replace() when str contains \

2022-10-29 Thread Dan Stromberg
I believe you would do well to print a, before trying to transform it into something else. '\2' is chr(2). '\a' is the bell character, and is unprintable. '\_' is two characters though. On Sat, Oct 29, 2022 at 2:12 PM Bernard LEDRU wrote: > Hello, > > https://docs.python.org/3/library/stdtypes.

Re: str.replace() when str contains \

2022-10-29 Thread Thomas Passin
Better to use raw strings whenever backslashes are involved. On 10/29/2022 2:21 PM, Bernard LEDRU wrote: Hello, https://docs.python.org/3/library/stdtypes.html#string-methods str.replace(old, new[, count])¶ Return a copy of the string with all occurrences of substring old replaced by new. If

Re: str.replace() when str contains \

2022-10-29 Thread Barry
> On 29 Oct 2022, at 22:14, Bernard LEDRU wrote: > > Hello, > > https://docs.python.org/3/library/stdtypes.html#string-methods > > str.replace(old, new[, count])¶ > Return a copy of the string with all occurrences of substring old replaced by > new. If the optional argument count is given,

str.replace() when str contains \

2022-10-29 Thread Bernard LEDRU
Hello, https://docs.python.org/3/library/stdtypes.html#string-methods str.replace(old, new[, count])¶ Return a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced. Attention when the