Add 'r' prefix to a python variable
<p>I have string variable which is </p>

<pre><code>temp = '1\2\3\4'
</code></pre>

<p>I would like to add a prefix 'r' to the string variable and get</p>

<pre><code>r'1\2\3\4'
</code></pre>

<p>so that I can split the string based on '\'. I tried the following:</p>

<pre><code>r'temp'
'r' + temp
r + temp
</code></pre>

<p>But none of the above works. Is there a simple to do it? I'm using python 3. I also tried to encode the string, using</p>

<pre><code>temp.encode('string-escape')
</code></pre>

<p>But it returns the following error</p>

<pre><code>LookupError: unknown encoding: string-escape
</code></pre>