title: Print Hex With Spaces Between
body: <p>I'm trying to print my hex out in another way...</p>
  
  <p>First I'm converting this (bytestring is the name of the variable):</p>
  
  <pre><code>b'\xff\x00\xff\xff\xff'
  </code></pre>
  
  <p>to hex,</p>
  
  <pre><code>print(bytestring.hex())
  </code></pre>
  
  <p>which outputs:</p>
  
  <pre><code>ff00ffffff
  </code></pre>
  
  <p>but I've been trying for a while to get it to output this:</p>
  
  <pre><code>ff 00 ff ff ff
  </code></pre>
  
  <p>but no luck.</p>
  
  <p>Any suggestions?
  Cheers!</p>
  
  <hr>
  
  <p>Update:</p>
  
  <pre><code>stringdata = f.read(5)
  print(stringdata)
  #b'\xff\x00\xff\xff\xff'
  
  readHex = " ".join(["{:02x}".format(x) for x in stringdata.hex()])
  # ValueError: Unknown format code 'x' for object of type 'str'
  </code></pre>