title: Convert from ASCII to Hex in Python
body: <p>I'm trying to convert a string with special characters from ASCII to Hex using python, but it doesn't seem that I'm getting the correct value, noting that it works just fine whenever I try to convert a string that has no special characters. So basically here is what I'm doing:</p>
  <pre><code>import binascii
  
  s = &quot;D`Cزف³›&quot;
  s_bytes = str.encode(s)
  hex_value = str(binascii.hexlify(s_bytes),'ascii')
  print (hex_value)
  </code></pre>
  <p><em><strong>Output</strong></em></p>
  <blockquote>
  <p>446043d8b2d981c2b316e280ba</p>
  </blockquote>
  <p>Where the output should be (using online converter <a href="https://www.rapidtables.com/convert/number/ascii-to-hex.html" rel="nofollow noreferrer">https://www.rapidtables.com/convert/number/ascii-to-hex.html</a>):</p>
  <blockquote>
  <p>446043632641b3203a</p>
  </blockquote>