+3 votes
in Programming Languages by (3.7k points)

I am running a Python code on Windows machine wherein I have mentioned the path to a directory like this:

ofile = 'C:\cygwin64\home\myuser\Research\temp' + '\' +  ifile

But I am getting the following error. How can I fix the error?

File "zipafile.py", line 8
    ofile = 'C:\cygwin64\home\myuser\Research\temp' + '\' +  ifile
                                                                                                       ^
SyntaxError: EOL while scanning string literal

1 Answer

0 votes
by (11k points)

You need to use '\\' instead of '\' in the variable ofile. '\' is used for escape character and hence it's giving error.

ofile = 'C:\\cygwin64\\home\\myuser\\Research\\temp' + '\\' +  ifile

...