title: How to translate byte escape sequence text to bytes in python (prepend with 'b') from string input - which encoding is proper for that?
body: <p>I've searched many websites, stackoverflow's replies, but have not found exact solution with my trouble, in example:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/63214198/when-creating-bytes-with-b-prefix-before-string-what-encoding-does-python-use">When creating bytes with &quot;b&quot; prefix before string, what encoding does python use?</a></li>
  <li><a href="https://stackoverflow.com/questions/48227005/how-to-encode-string-to-bytes-in-python">How to encode string to bytes in python?</a></li>
  </ul>
  <p>My example – I can't understand what encoding will give same result as phrase preceded by with 'b' on escaped string:</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; txt_bz = b'BZh91AY&amp;SY^\x85\xab\xd2\x00\x00\x00\x81\x80\x02\x02\x1c  \x000\xc0\x08a\xa5\x1a\x03\x0b\xb9&quot;\x9c(H/B\xd5\xe9\x00'
  &gt;&gt;&gt; txt_cmp = bytes('BZh91AY&amp;SY^\x85\xab\xd2\x00\x00\x00\x81\x80\x02\x02\x1c  \x000\xc0\x08a\xa5\x1a\x03\x0b\xb9&quot;\x9c(H/B\xd5\xe9\x00', 'utf-8')
  &gt;&gt;&gt; txt_cmp==txt_bz
  False
  &gt;&gt; txt_cmp = bytes('BZh91AY&amp;SY^\x85\xab\xd2\x00\x00\x00\x81\x80\x02\x02\x1c  \x000\xc0\x08a\xa5\x1a\x03\x0b\xb9&quot;\x9c(H/B\xd5\xe9\x00', 'unicode-escape')
  &gt;&gt;&gt; txt_cmp==txt_bz
  False
  </code></pre>