title: How to create a dump file in hex format from python
body: <p>I have a array of integer which I want to dump in one binary file (HEX file to be specific) using python script
  I have written a code as </p>
  
  <pre><code>MemDump = Debug.readMemory(ic.IConnectDebug.fRealTime, 0, 0xB0009CC4, 0xCFF, 1)
  
      MemData = MemDump[:3321]
      # Create New file in binary mode and open for writing
      fp = open("MON.dmp", 'w')
      sys.stdout = fp
      for byte in MemData:
          print(byte)
  </code></pre>
  
  <p>Here MemDump contains an array of integer values. From this array first 3321 bytes I want to dump in file.
  Here I am getting the the output in file MON.dmp but in ASCII fromat.
  and if I create file in binary format using </p>
  
  <pre><code>fp = open("MON.dmp", 'wb')
  </code></pre>
  
  <p>print(byte) command gives me an error saying </p>
  
  <pre><code>'str' does not support the buffer interface
  </code></pre>
  
  <p>Thank you in Advance. </p>