title: Splitting a hexadecimal string into chunks in Python
body: <p>I have this part of code in Python:</p>
  
  <pre><code>for line in response.body.split("\n"):
      if line != "": 
          opg = int(line.split(" ")[2])
          opc = int(line.split(" ")[3])
          value = line.split(" ")[5]
          if command == 'IDENTIFY':
              if opg==opcodegroupr and opc==opcoder:
                  print line
                  ret['success'] = "IDENTIFY: The value is %s " % (value)
                  self.write(tornado.escape.json_encode(ret))
                  self.finish()
  </code></pre>
  
  <p>Variable 'line' is made in this way:</p>
  
  <pre><code>1363005087 2459546910990453036 151 88 4 0x15000000
  </code></pre>
  
  <p>Every field is an integer, but not the last field. The last field is an hex number.</p>
  
  <p>I would take this hex number and after split byte per byte. For example I would that 
  0x15000000 was splitted in 15 00 00 00.</p>
  
  <p>How can I do? I tried with value.encode("hex") but dowsn't work fine... value is a string? I don't know how consider this variable..</p>