Can somebody please tell me how do I read the result b'\x9a\x99\x99?' of
import struct
data = struct.pack("@f", 1.2)
print(data)
What does \x9a represent? Or \x99? How do I translate this back to 1.2?
abhilb
5,7572 gold badges22 silver badges26 bronze badges
1 Answer 1
The data is stored in a binary format. To get the value back, use struct.unpack:
import struct
data = struct.pack("@f",1.2)
print(struct.unpack("@f",data))
Related: Why won't Python display this text correctly? (UTF-8 Decoding Issue)
answered Jan 24, 2020 at 13:19
GoodDeeds
8,6375 gold badges40 silver badges69 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py