How To Decode A Dat File In Python?
I'm trying to read bytes from a DAT file. I know the data is supposed to be in either Binary or Hex. But when I try to read the bytes it prints out weird symbols. I'm assuming they
Solution 1:
If your .dat
file is not text, you should open it as a binary file with 'rb'
(per Python docs):
withopen('Example CARESCAPE Datalog.dat', 'rb') as binary_file:
You'll have to decode the bytes yourself:
Note: Files opened in binary mode (including 'rb' in the mode argument) return contents as bytes objects without any decoding.
Post a Comment for "How To Decode A Dat File In Python?"