'Meaning of unusual "hex" values which are understood by my program

I'm reading data from bluetooth device using Python script. Device returns a value written in hex on six bytes. I ignore the first two because they are status bytes, then by using struct.unpack() program translates hex value to an int using little endian as a parameter. For example: \xd1\x9e\x00\x00 is properly translated to 40657, however sometimes raw data of those four bytes sent by device reads (by using print() on a variable storing raw data) as such: "\x9cQ\x00\x00" and is translated without issues by struct.unpack(), returns a valid value, which based on how device works is a perfectly correct value. My question is why instead of first two of meaningful bytes it shows this "\x9cQ" monstrosity and more than that why is it even understood by struct.unpack()? I always thought hex could only store values 0-9, a, b, c, d, e, f. Is it because print() doesn't work well with a variable storing raw hex data or is it some kind of unusual hex coding I'm not aware of? I'm just curious because program works perfectly fine even with these weird values.



Sources

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

Source: Stack Overflow

Solution Source