Hand have a dat file, it is 16 bit image data from the serial port, using matlab fscanf (fid, '% x) can be read out an integer value, but can only read out bytes in python types of data, such as b' FBB 'this, want to ask how to read binary file in python, can be used to check the data struct package, but I dat file data bytes is different, there are 3 byte and 4 byte, b' FBB 'and b' 13 e4 'this, with struct. The unpack () when the cache does not match, there are other ways to read binary files?
CodePudding user response:
Try to shelve module