In python the \ character is an escape character, so you are escaping the " at the end of the string. This is kind of an edge case. However, removing that \ is functionally equivalent. If you intend to use this as a sub string in building a larger path, then adding format place holders will allow you to use this as you're trying.
In basically everything in Python and Java's standard library, you can just use forward slashes instead of backslashes and avoid any escaping problems entirely.
So, even on a 'raw' string, the backslash at the end acts as an escape? I'm having trouble making sense of that since it didn't do that with the other backslashes in the string. Any idea why only the last character seems to be a special case?
For those (like me) who are still having trouble understanding it, I just stumbled across this document that explains about this particular topic for Python in general. Why can't raw strings in Python end with a backslash?
It still seems odd to me. But I tend to remember odd things, so maybe that's good?
What if production has a database with thousands of records that are just file paths on a network drive?
One path example would be "C:\folder1\folder2\folder3\items", that is how they're stored in our DB. I am trying to pull the paths from the db and then represent them in a tree view.