Understanding Python's backslash escape character
<p>My script creates files to export by concatenating a file path with a file type suffix. For example,</p>

<pre><code>int = 3
print r"C:\Test\\" + str(int) + ".jpg"
</code></pre>

<p>This returns <code>C:\Test\\3.jpg</code></p>

<p>I thought that because I included the 'r' at the beginning, I wouldn't need a double backslash at the end, because it'd be treated as a raw string. But the following doesn't work:</p>

<pre><code>int = 3
print r"C:\Test\" + str(int) + ".jpg"
</code></pre>

<p>...presumably because Python is seeing an escape character before the end quote. So what's the point of the 'r' then? And while my files get saved in the right place when exported, I don't like that the print command gives me two backslashes after Test (eg C:\Test\3.jpg) when it just gives me one after C:</p>

<p>How can I get a single backslash in my file paths please?</p>

<p>Thanks</p>
