title: How do you decode an ascii string in python?
body: <p>For example, in your python shell(IDLE):</p>
  
  <pre><code>&gt;&gt;&gt; a = "\x3cdiv\x3e"
  &gt;&gt;&gt; print a
  </code></pre>
  
  <p>The result you get is:</p>
  
  <pre><code>&lt;div&gt;
  </code></pre>
  
  <p>but if <code>a</code> is an ascii encoded string:</p>
  
  <pre><code>&gt;&gt;&gt; a = "\\x3cdiv\\x3e" ## it's the actual \x3cdiv\x3e string if you read it from a file
  &gt;&gt;&gt; print a
  </code></pre>
  
  <p>The result you get is:</p>
  
  <pre><code>\x3cdiv\x3e
  </code></pre>
  
  <p>Now what i really want from <code>a</code> is <code>&lt;div&gt;</code>, so I did this:</p>
  
  <pre><code>&gt;&gt;&gt; b = a.decode("ascii")
  &gt;&gt;&gt; print b
  </code></pre>
  
  <p>BUT surprisingly I did NOT get the result I want, it's still: </p>
  
  <pre><code>\x3cdiv\x3e
  </code></pre>
  
  <p>So basically what do I do to convert <code>a</code>, which is <code>\x3cdiv\x3e</code> to <code>b</code>, which should be <code>&lt;div&gt;</code>?</p>
  
  <p>Thanks</p>