'How to decode b'a\xXX format

I'm trying to read data from .db3 file, this is how I get each row in database .db3 the table is MBinary and the column is five_bboxes (https://i.stack.imgur.com/DiN96.png) con = sqlite3.connect(fileName) cursorID = con.cursor() # to record ID

    cursor = con.cursor()  # to get data

    cursor.execute('SELECT five_bboxes FROM MBinary')

    for row in cursor.fetchall():

        zobj = zlib.decompressobj()
        unknown_data = zobj.decompress(row[0])
        print(f"unknown_data:{unknown_data}")

OUTPUT:

unknown_data:b'a\x00\x00\x00\xe2\x00\x00\x00\xb5\x00\x00\x00\xf3\x02\x00\x00\xa3\x00\x00\x00\xd0\x00\x00\x00\xf1\x00\x00\x00\xf6\x02\x00\x00u\x00\x00\x00\xd4\x00\x00\x00\xff\x00\x00\x00\x00\x03\x00\x00c\x00\x00\x00\xd7\x00\x00\x00\xe6\x00\x00\x00e\x01\x00\x00a\x00\x00\x00n\x02\x00\x00\xf1\x00\x00\x00\xfa\x02\x00\x00'



Solution 1:[1]

The b'foo' stuff is how Python formats a byte array for printing, so what you have there is most likely a bytes object. These are described in the "Built-in Types" section of the Python library reference manual.

The struct module of the standard library may be useful in decoding the bytes to something useful, but that depends entirely on what those bytes represent and how it is encoded, which is not a Python question.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ture PÄlsson