here is that \ is taken to stand for newline characterand \ is replaced with tab in effectthe call tries to open file named :(newline)ew(tab)ext datwith usually lessthan-stellar results this is just the sort of thing that raw strings are useful for if the letter (uppercase or lowercaseappears just before the opening quote of stringit turns off the escape mechanism the result is that python retains your backslashes literallyexactly as you type them thereforeto fix the filename problemjust remember to add the letter on windowsmyfile open( ' :\new\text dat'' 'alternativelybecause two backslashes are really an escape sequence for one backslashyou can keep your backslashes by simply doubling them upmyfile open(' :\\new\\text dat'' 'in factpython itself sometimes uses this doubling scheme when it prints strings with embedded backslashespath ' :\new\text datpath ' :\\new\\text datprint(pathc:\new\text dat len(path show as python code user-friendly format string length as with numeric representationthe default format at the interactive prompt prints results as if they were codeand therefore escapes backslashes in the output the print statement provides more user-friendly format that shows that there is actually only one backslash in each spot to verify this is the caseyou can check the result of the built-in len functionwhich returns the number of characters in the stringindependent of display formats if you count the characters in the print(pathoutputyou'll see that there really is just character per backslashfor total of besides directory paths on windowsraw strings are also commonly used for regular expressions (text pattern matchingsupported with the re module introduced in and also note that python scripts can usually use forward slashes in directory paths on windows and unix because python tries to interpret paths portably ( ' :/new/text datworks when opening filestooraw strings are useful if you code paths using native windows backslashesthough string literals