I have the following 8 byte string that forms part of a binary file
b = b'?\xf0\x00\x00\x00\x00\x00\x00'
and I want to convert it to a floating point number (which should be equal to 7.371791007870371e+05). None of the approaches that I've tried so far have worked:
literal_eval
from ast import literal_eval literal_eval(b) ValueError: malformed node or string: b'?\xf0\x00\x00\x00\x00\x00\x00'
following @martineau's answer in this post: How to convert a binary (string) into a float value?
ValueError: invalid literal for int() with base 2: b'?\xf0\x00\x00\x00\x00\x00\x00'
In both cases the errors raised suggest that the string 'b' is invalid, but I don't see how this is possible as it's read straight from the binary file.