title: String to \x escaped hex ascii
body: <p>i am working with sockets (some DNS stuff) and i can't figure out how from this:</p>
  
  <pre><code>a = 'www'
  </code></pre>
  
  <p>make</p>
  
  <pre><code>b = b'\x77\x77\x77'
  </code></pre>
  
  <p>I know/think i need to:</p>
  
  <p>1) convert each to hex value with <code>hex(ord(char))</code></p>
  
  <p>2) format it from '0x77' to '\x77'</p>
  
  <p>3) convert it to bytes with <code>bytes(a,'utf-8')</code></p>
  
  <p>I tried many combinations, but i always failed at 2) and generally i think my steps are too complicated. Is there some simple solution to this?</p>