python - Convert hex to float -


How to change the following hex string for float (single precision 32-bit) in Python?

  "41973333" - & gt; 1.88999996185302734375 E1 "41995C29" - & gt; 1.91700000762939453125 E1 "470FC614" - & gt; 3.6806078125E4  

  & gt; & Gt; & Gt; Import structure & gt; & Gt; & Gt; Struct.unpack ('! F', '41973333'.decode (' hex ')) [0] 18.899999618530273 & gt; & Gt; & Gt; Struct.unpack ('! F', '41995C29' DXOD ('HEX')) [0] 19.170000076293945 & gt; & Gt; & Gt; Struct.unpack ('! F', '470FC614'.decode (' hex ')) [0] 36806.078125  

Update: How to do it See comment on Python 3.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -