title: Python string representation of binary data
body: <p>I'm trying to understand the way Python displays strings representing binary data.</p>
  
  <p>Here's an example using <a href="http://docs.python.org/library/os.html#os.urandom">os.urandom</a></p>
  
  <pre><code>In [1]: random_bytes = os.urandom(4)
  
  In [2]: random_bytes
  Out[2]: '\xfd\xa9\xbe\x87'
  
  In [3]: random_bytes = os.urandom(4)
  
  In [4]: random_bytes
  Out[4]: '\r\x9eq\xce'
  </code></pre>
  
  <p>In the first example of <code>random_bytes</code>, after each \x there seem to be values in hexadecimal form: fd a9 be 87.</p>
  
  <p>In the second example, however, I don't understand why <code>'\r\x9eq\xce'</code> is displayed.</p>
  
  <p>Why does Python show me these random bytes in this particular representation? How should I interpret <code>'\r\x9eq\xce'</code>?</p>