Nov-16-2016, 08:39 PM
That has nothing to do with files. Backslash (ie: \) is an escape character. If you want to actually use one in a string, you need to escape it: \\. The only reason it's working for you, is because you marked the string as raw (that's what the "r" in front of your path means). You could also use a single forward slash... python will do The Right Thing depending on what os you're on, so "c:/temp/test.txt" == "c:\\temp\\test.txt" == r"c:\temp\test.txt" == "c:/temp\\test.txt" == r"c:/temp\test.txt".
...but don't mix between the two in a single string. Other people will hate you for purposefully making things hard to read, lol.
...but don't mix between the two in a single string. Other people will hate you for purposefully making things hard to read, lol.