Unable to resolve EOL error while using chdir along with path in python
<p>Code</p>

<pre><code>os.chdir(os.path.normpath(r"D:\mystuff\Ear\APP-INF\lib\extract-dto"))
</code></pre>

<p>I have tried other code sample :</p>

<pre><code>os.chdir("D:\\mystuff\\ekaEar\\APP-INF\\lib\\extract-dto")
</code></pre>

<p>Output:</p>

<pre><code>File "CreateJar.py", line 13
os.chdir(os.path.normpath('D:\mystuff\Ear\APP-INF\lib\'))
                                                        ^
SyntaxError: EOL while scanning string literal
</code></pre>

<p>I think \e is escape sequence character not sure.</p>

<p>How to prevent this error?</p>

<p>It looks like the backslash at the end of the path is causing the single quote to be escaped. If possible, try removing the last backslash from the path.</p>

<pre><code>os.chdir(os.path.normpath('D:\mystuff\Ear\APP-INF\lib'))
</code></pre>

<p>If your path is stored in a variable, you can do this with code using something like the this:</p>

<pre><code>my_path.rstrip('\\')
</code></pre>

python cmd