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 <pyt...@bernardledru.be> 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 occurrences are replaced. > > Attention when the string contains the escape character. > > Consider : > > >>> a="H:\2023"; print(a.replace("\\","/")) > H:3 > >>> a="H:\a2023"; print(a.replace("\\","/")) > H:2023 > >>> a="H:\_2023"; print(a.replace("\\","/")) > H:/_2023 > > Best regards, > Bernard LEDRU > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list