I've encountered a problem in Python when dealing with backward slashes followed by numbers inside a string. I use windows OS environment.
This becomes especially annoying when you have numbers in the beginning of a name in a directory.
Ex: "P:\70_parseFile\80_FileDir\60_FA_050"
This was a discovery for me that you can create special characters if you do "\1", "\2", "\3"... and so on. As wonderful as this seems, I have to ask on how to go about turning this off, or what other different string function is there that doesn't have this special feature?
Thanks, all!
You have two choices:
Backslash those backslashes:
"P:\\70_parseFile\\80_FileDir\\60_FA_050"
Use a raw string, in which the backslash loses its "special meaning"
r"P:\70_parseFile\80_FileDir\60_FA_050"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With