将十六进制字符串表示形式转换为 python 中的浮点数

Converting hex string representation to float in python

我有 IEEE 745 十六进制格式的数据:0x1.5c28f5c28f5c3p-1

如何将其转换为 python 中的浮点数?这是标准模块吗?

>>> float.fromhex('0x1.5c28f5c28f5c3p-1')
0.68

它在标准库中,float.fromhex

啊哈:

它在标准库中,"float.fromhex",

https://docs.python.org/2/library/stdtypes.html#float.fromhex