Jul-21-2022, 11:25 AM
(This post was last modified: Jul-21-2022, 11:25 AM by deanhystad.)
Your problem starts with
To fix the problem you have to fix the str. Use "\\" if you want the str to contain "\" as a character, or use raw strings.
Path = 'D:\My Directory1\bin'Path does not contain the string "\b". "\b" is an escape sequence for the back space character, so "Directory1\bin" is really "Directoryin". The substitution of "\b" with backspace has already happened before you try to replace or substitute. Your attempts fail because there is no backslash to replace.
To fix the problem you have to fix the str. Use "\\" if you want the str to contain "\" as a character, or use raw strings.
path = r'D:\My Directory1\bin' path = 'D:\\My Directory1\\bin'Of possible interest "\M" is just a str with a backslash followed by "M". This is because "\M" is not a recognized escape sequence like \b, \f, \n, \o, \r, \t, \u, \x