bin2hex.py 313 B

12345678910111213141516
  1. #!/usr/bin/env python3
  2. import struct
  3. import sys
  4. def main(argv0, in_name, out_name):
  5. with open(in_name, 'rb') as in_fh, open(out_name, 'w') as out_fh:
  6. while True:
  7. b = in_fh.read(4)
  8. if len(b) < 4:
  9. break
  10. out_fh.write('%08x\n' % struct.unpack('<I', b))
  11. if __name__ == '__main__':
  12. main(*sys.argv)