Decoding COMP-3 packed fields in an ASCII file in Python?
问题 I have a file that was formerly an EBCDIC-encoded file, which was converted to ASCII using dd. However, some lines contain COMP-3 packed fields which I would like to read. For example, the string representation of one of the lines I would like to decode is: '15\x00\x00\x00\x04@\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x0c777093020141204NNNNNNNNYNNNN\n' The field I would like to read is specified by PIC S9(09) COMP-3 POS. 3 , that is, the field that starts with the third byte and is nine bytes long