This has probably answered somewhere at sometime but the titles I have seen don't connect so here it goes. I have seen python commands that read os.listdir(r".\bootstrapper"). What is the 'r' doing?
Cheers...
it prevents the Python interpreter from attaching any special meanings to special characters in the string (such as the backslash), and just interpret it as is (i.e., in its "raw" form). This is one way you can "escape" special characters in strings you use.
You'll often see raw strings in path specifications. Let's say the path contains a directory that starts with t, e.g., c:\tests\data.csv, so you'd not want \t to be interpreted as a tab, hence use the r modifier.
r marks raw input. This means that the normal escape characters within the string are ignored (like \ )
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