<p>For example, if I have a <em>unicode</em> string, I can encode it as an <em>ASCII</em> string like so:</p>

<pre><code>&gt;&gt;&gt; u'\u003cfoo/\u003e'.encode('ascii')
'&lt;foo/&gt;'
</code></pre>

<p>However, I have e.g. this <em>ASCII</em> string:</p>

<pre><code>'\u003foo\u003e'
</code></pre>

<p>... that I want to turn into the same <em>ASCII</em> string as in my first example above:</p>

<pre><code>'&lt;foo/&gt;'
</code></pre>

It's a little dangerous depending on where the string is coming from, but how about:
```
```
>>> s = '\u003cfoo\u003e'
>>> eval('u"'+s.replace('"', r'\"')+'"').encode('ascii')
'<foo>'
```
```