Python 2.X
1. 以十六进制 41F00000为例;
import struct
struct.unpack('!f','41F00000'.decode('HEX'))[0]
2.输出结果如下:返回浮点数30.0;
Python 3.X
1.同样以十六进制 41F00000为例;
import struct
struct.unpack('!f',bytes.fromhex('41F00000'))[0]
2.输出结果如下:返回浮点数30.0;其他转换示例供参考练习。
关联报错:AttributeError: type object 'str' has no attribute 'fromhex'