title: String to Bytes Python without change in encoding
body: <p>I have this issue and I can't figure out how to solve it. I have this string:</p>
  
  <pre><code>data = '\xc4\xb7\x86\x17\xcd'
  </code></pre>
  
  <p>When I tried to encode it:</p>
  
  <pre><code>data.encode()
  </code></pre>
  
  <p>I get this result:</p>
  
  <pre><code>b'\xc3\x84\xc2\xb7\xc2\x86\x17\xc3\x8d'
  </code></pre>
  
  <p>I only want:</p>
  
  <pre><code>b'\xc4\xb7\x86\x17\xcd'
  </code></pre>
  
  <p>Anyone knows the reason and how to fix this. The string is already stored in a variable, so I can't add the literal b in front of it.</p>