title: Convert string with escaped characters and ASCII values into HEX
body: <p>I have the following string which contains escaped HEX values and ASCII characters</p>
  
  <pre><code>"\01B\2E\00   k\00"
  </code></pre>
  
  <p>A backslash means that the next two characters are HEX values, everything else in the  string is ASCII</p>
  
  <p>The goal is to convert the entire string into all HEX values</p>
  
  <p>end result:</p>
  
  <pre><code>"\01\42\2E\00\20\20\20\6B\00"
  </code></pre>
  
  <p><em>::edit::</em></p>
  
  <p>I had tried the following:</p>
  
  <pre><code>s = "\01B\2E\00   k\00"
  r = [ ]
  
  for x in s:
      r.append(x.encode("hex"))
  
  print r
  </code></pre>
  
  <p>the problem was the values (ex:  \1E ) were being interpreted as \x01 and E</p>
  
  <p>Then i ran into the following question <a href="https://mail.python.org/pipermail/tutor/2008-April/061025.html" rel="nofollow">online</a> came to post an update, and realized my question was already answered.</p>
  
  <p>Thanks</p>