title: Python: Convert Raw String to Bytes String without adding escape chraracters
body: <p>I have a string:</p>
  
  <pre><code>'BZh91AY&amp;SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07&lt;]\xc9\x14\xe1BA\x06\xbe\x084'
  </code></pre>
  
  <p>And I want:</p>
  
  <pre><code>b'BZh91AY&amp;SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07&lt;]\xc9\x14\xe1BA\x06\xbe\x084'
  </code></pre>
  
  <p>But I keep getting:</p>
  
  <pre><code>b'BZh91AY&amp;SYA\\xaf\\x82\\r\\x00\\x00\\x01\\x01\\x80\\x02\\xc0\\x02\\x00 \\x00!\\x9ah3M\\x07&lt;]\\xc9\\x14\\xe1BA\\x06\\xbe\\x084'
  </code></pre>
  
  <p><strong>Context</strong></p>
  
  <p>I scraped a string off of a webpage and stored it in the variable <code>un</code>. Now I want to decompress it using BZip2:</p>
  
  <pre><code>bz2.decompress(un)
  </code></pre>
  
  <p>However, since <code>un</code> is a <code>str</code> object, I get this error:</p>
  
  <pre><code>TypeError: a bytes-like object is required, not 'str'
  </code></pre>
  
  <p>Therefore, I need to convert <code>un</code> to a bytes-like object without changing the single backslash to an escaped backslash.</p>
  
  <p><strong>Edit 1:</strong>
  Thank you for all the help!
  @wim I understand what you mean now, but I am at a loss as to how I can retrieve a bytes-like object from my webscraping method:</p>
  
  <pre><code>r = requests.get('http://www.pythonchallenge.com/pc/def/integrity.html')
  
  doc = html.fromstring(r.content)
  comment = doc.xpath('//comment()')[0].text.split('\n')[1:3]
  
  pattern = re.compile("[a-z]{2}: '(.+)'")
  
  un = re.search(pattern, comment[0]).group(1)
  </code></pre>
  
  <p>The packages that I am using are <code>requests</code>, <code>lxml.html</code>, <code>re</code>, and <code>bz2</code>.</p>
  
  <p>Once again, my goal is to decompress <code>un</code> using <code>bz2</code>, but I am having difficulty getting a bytes-like object from my webscraping process.</p>
  
  <p>Any pointers?</p>