title: python string.format and invalid \x escape
body: <p>I'm trying to format a string with some <code>\x</code> inside in python. </p>
  
  <p>When I use:</p>
  
  <pre><code>print '\x00\x00\xFF\x00'
  </code></pre>
  
  <p>it works nicely and print <code>�</code>. But when I try to format the string:</p>
  
  <pre><code>print '\x{}\x{}\x{}\x{}'.format('00','00','FF','00')
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>ValueError: invalid \x escape
  </code></pre>
  
  <p>The problem when I escape the backslash like this:</p>
  
  <pre><code>print '\\x{}\\x{}\\x{}\\x{}'.format('00','00','FF','00')
  </code></pre>
  
  <p>It prints:</p>
  
  <pre><code>\x00\x00\xFF\x00
  </code></pre>
  
  <p>And not the little <code>�</code> like the non-formatted string.</p>
  
  <p><code>chr</code> and <code>bytearray</code> seem interesting for example:</p>
  
  <p><code>print chr(0x00),chr(0x00),chr(0xFF),chr(0x00)</code> or <code>print bytearray([0x00, 0x00, 0xFF, 0x00])</code> </p>
  
  <p>prints <code>�</code>, but when I try to format them, I get a SyntaxError.</p>
  
  <p>I found some interesting posts like:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/16741435/why-cant-pythons-string-format-pad-with-x00">Why can&#39;t Python&#39;s string.format pad with &quot;\x00&quot;?</a></li>
  <li><a href="https://stackoverflow.com/questions/21017698/converting-int-to-bytes-in-python-3">Converting int to bytes in Python 3</a></li>
  </ul>
  
  <p>But I'm still stuck...</p>
  
  <p>How to print a formatted string with <code>\x</code> inside?</p>
  
  <p>(I'm using python 2.7 but I can use an other version.)</p>
  
  <p>Thank you</p>