I'm going to expand on on Elzar's correct answer and your comment. What might have gotten you confused and is left unsaid in the previous answers is that there is a difference between the Python string, as you provide it in the source code, and as the python console and IDEs show it to you, the developer, and the way the string is printed, i.e. displayed to the user:
>>> s = 'c:\\directory\\file.txt'
>>> s
'c:\\directory\\file.txt' <-- if you ask for the value, you will see double slashes
>>> print s
c:\directory\file.txt <-- if you print the string, the user will see single slashes
I think the reason you you're getting "The system cannot find the path specified." is because you manually copy to clipboard and paste something from the Python console/IDE (also supported by the fact that your path is shown in quotes in your question).
To add to the confusion, you will sometimes get away with single quotes. Only some slash-character combinations have a special meaning (see Python documentation), e.g. '\n'
for a new line and others don't, e.g. '\s'
, which just prints as \s
.
As a side note, the reason for escaped characters is that they are a convenient way for Python/the computer in general to communicate to the programmer what special characters there are in the text. This way, for example, there's no ambiguity between '\t'
(tab character) and ' '
(a number of spaces), unprintable/some control characters can actually be seen, etc.