title: python cannot struct.pack struct.error: cannot convert argument to integer
body: <p>I read from a hex file that's 1444352kB of size. I take 128 bytes of data and try to pack them using python struct.pack.</p>
  
  <p>Below is the code :</p>
  
  <pre><code>#!/usr/bin/env python
  import os
  import struct
  import ctypes
  import array
  import binascii
  
  import sys,getopt
  
  filename = file_location
  blocksize = 1444352
  
  opts,args = getopt.getopt(sys.argv[1:],'f:b:')
  for o,a in opts:
      if o == '-f':
      filename = a
  if o == '-b':
      blocksize = a
  
  offset = 0
  with open(filename,"rb") as f:
  block = f.read(blocksize)
  str = ""
  for ch in block:
      str += hex(ord(ch))+" "
  
  
  sector = []
  c = 0
  for s in str.split(' ') :
      sector.append(s)
      c += 1
      if c == 128 :
          sector.append("")
          c = 0
          #print sector
          sector  = ', '.join(sector)
          #print sector
          print type(sector)
          sector = sector.split(',')
          secdata = []
          for items in sector[0:127] :
              secdata.append(items)
          secdata2 = ','.join(secdata)
          print secdata2
          print type(secdata2)
          struct.pack('B', secdata2)
          break
  </code></pre>
  
  <p>The secdata that appears to be a list, I have converted to string. but I always get error <code>struct.error: cannot convert argument to integer</code> when I try to pack the 128 bytes of data.</p>